Issue
I was trying to run a simple server in Deno and typescript but I keep having this error:
error: TS2739 [ERROR]: Type '{ localAddr: { transport: "tcp"; hostname: string; port:
number; }; remoteAddr: { transport: "tcp"; hostname: string; port: number; }; rid:
number; close(): void; closeWrite(): Promise<void>; read(p: Uint8Array): Promise<...>;
write(p: Uint8Array): Promise<...>; }' is missing the following properties from type
'Conn': readable, writable
const conn: Deno.Conn = {
~~~~
at https://deno.land/x/servest@v1.3.1/testing.ts:41:9
I use this code from the servest documentation:
// @deno-types="https://deno.land/x/servest@v1.3.1/types/react/index.d.ts"
import React from "https://dev.jspm.io/react/index.js";
// @deno-types="https://deno.land/x/servest@v1.3.1/types/react-dom/server/index.d.ts"
import ReactDOMServer from "https://dev.jspm.io/react-dom/server.js";
import { createApp } from "https://deno.land/x/servest@v1.3.1/mod.ts";
const app = createApp();
app.handle("/", async (req) => {
await req.respond({
status: 200,
headers: new Headers({
"content-type": "text/html; charset=UTF-8",
}),
body: ReactDOMServer.renderToString(
<html>
<head>
<meta charSet="utf-8" />
<title>servest</title>
</head>
<body>Hello Servest!</body>
</html>,
),
});
});
app.listen({ port: 8899 });
I searched everywhere and I can't find an answer, I'm using deno v1.19.1
Solution
One of the files that is downloaded by Deno as part of your program's dependency tree is the following:
https://deno.land/x/servest@v1.3.1/testing.ts
In the error message you can see that there is a TypeError when typechecking this file, because Deno.Conn
is missing the readable
and writeable
properties.
If you visit https://deno.land/x/servest@v1.3.1/testing.ts#L41 you can see it declares a variable conn
of type Deno.Conn
which does not have these properties indeed. Deno added readable
and writeable
to Deno.Conn in 1.19, so the type of conn
declared in Servest 1.3.1 is not the same as the type of Deno.Conn
in Deno 1.19. You could inform the authors of the code of this issue so they can fix it. In the meantime you could use Deno 1.18, where this type has not changed yet.
Answered By - Zwiers
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.