【发布时间】:2021-01-01 20:54:27
【问题描述】:
于是我开始学习 Deno。安装 Deno 后(我在 WSL 中使用 Curl curl -fsSL https://deno.land/x/install/install.sh | sh),我想运行服务器。一旦运行deno run index.ts,我得到这些typescript 错误。
$ deno run index.ts
Compile file:///C:/Users/User/Works/tw_revamp_deno_server/index.ts
error TS2304: Cannot find name 'TransformStream'.
const res = new TransformStream<Promise<R>, R>({
~~~~~~~~~~~~~~~
at https://deno.land/std@0.69.0/async/pool.ts:18:19
error TS2304: Cannot find name 'TransformStreamDefaultController'.
controller: TransformStreamDefaultController<R>,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/std@0.69.0/async/pool.ts:21:19
error TS2322: Type 'Uint8Array | undefined' is not assignable to type 'Uint8Array | null'.
Type 'undefined' is not assignable to type 'Uint8Array | null'.
return line;
~~~~~~~~~~~~
at https://deno.land/std@0.69.0/textproto/mod.ts:149:5
Found 3 errors.
我的 index.ts 文件很简单,与给出的示例类似。
import { serve } from "https://deno.land/std@0.69.0/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
for await (const req of s) {
req.respond({ body: "Hello World\n" });
}
任何人都遇到过类似的错误并且知道如何解决。随意回复。谢谢
【问题讨论】:
标签: typescript deno