【问题标题】:Deno and oak error: TS2315 [ERROR]: Type 'Conn' is not generic - with Deno using oak as server on macOs with basic example codeDeno 和 Oak 错误:TS2315 [错误]:类型“Conn”不是通用的 - Deno 在 macOS 上使用 Oak 作为服务器,带有基本示例代码
【发布时间】: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 });

谢谢!

【问题讨论】:

    标签: deno oak


    【解决方案1】:

    该错误来自早于 1.9 的 deno 与晚于 v7 的 Oak 之间的不兼容。

    自从我几个小时前安装了 deno 以来,我没有检查版本。使用自制软件我得到了一个旧版本 - 现在我使用了

    curl -fsSL https://deno.land/x/install/install.sh | sh 
    

    改为。

    【讨论】:

      猜你喜欢
      • 2020-09-29
      • 2022-11-10
      • 1970-01-01
      • 1970-01-01
      • 2021-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-06
      相关资源
      最近更新 更多