【发布时间】:2021-04-18 18:18:38
【问题描述】:
我正在尝试 Deno 与橡木 并且每次都遇到相同的错误 - 即使我尝试默认示例也是如此。我的工作环境是 macOS Big Sur。有人知道如何解决这个问题吗?
$ deno run --allow-net server.ts
Check file:///.../server.ts
error: TS2315 [ERROR]: Type 'Conn' is not generic.
export function isConn(value: unknown): value is Deno.Conn<Deno.NetAddr> {
~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/oak@v7.2.0/util.ts:66:50
TS2315 [ERROR]: Type 'Conn' is not generic.
#conn?: Deno.Conn<Deno.NetAddr>;
~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/oak@v7.2.0/http_server_native.ts:41:11
TS2315 [ERROR]: Type 'Conn' is not generic.
constructor(requestEvent: RequestEvent, conn?: Deno.Conn<Deno.NetAddr>) {
~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/oak@v7.2.0/http_server_native.ts:49:50
TS2315 [ERROR]: Type 'Conn' is not generic.
async function serve(conn: Deno.Conn<Deno.NetAddr>) {
~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/oak@v7.2.0/http_server_native.ts:149:36
TS2315 [ERROR]: Type 'Conn' is not generic.
conn?: Deno.Conn<Deno.NetAddr>,
~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/oak@v7.2.0/application.ts:50:12
TS2315 [ERROR]: Type 'Conn' is not generic.
secureOrConn: Deno.Conn<Deno.NetAddr> | boolean | undefined,
~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/oak@v7.2.0/application.ts:374:19
Found 6 errors.
示例代码来自这里 (https://github.com/oakserver/oak),如下所示:
import { Application } from "https://deno.land/x/oak/mod.ts";
const app = new Application();
app.use((ctx) => {
ctx.response.body = "Hello World!";
});
await app.listen({ port: 8000 });
谢谢!
【问题讨论】: