Deno and oak error: TS2315 [ERROR]: Type 'Conn' is not generic - with Deno using oak as server on macOs with basic example code
Deno and oak error: TS2315 [ERROR]: Type 'Conn' is not generic - with Deno using oak as server on macOs with basic example code
我正在尝试 Deno with oak 并且我 运行 每次都遇到同样的错误 - 即使我尝试默认示例也是如此。我的工作环境是 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 });
谢谢!
错误是由于1.9之前的deno和v7之后的oak不兼容造成的
因为我几个小时前安装了 deno,所以我没有检查版本。使用自制软件我得到了一个旧版本 - 现在我使用
curl -fsSL https://deno.land/x/install/install.sh | sh
相反。
我正在尝试 Deno with oak 并且我 运行 每次都遇到同样的错误 - 即使我尝试默认示例也是如此。我的工作环境是 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 });
谢谢!
错误是由于1.9之前的deno和v7之后的oak不兼容造成的
因为我几个小时前安装了 deno,所以我没有检查版本。使用自制软件我得到了一个旧版本 - 现在我使用
curl -fsSL https://deno.land/x/install/install.sh | sh
相反。