gpt4 book ai didi

typescript - Deno REPL 无法识别 TypeScript 变量声明

转载 作者:行者123 更新时间:2023-12-05 00:45:57 24 4
gpt4 key购买 nike

我使用 Chocolatey 在 Windows 10 上安装了 Deno 1.0.5。我尝试在 Deno REPL 中使用 Typescript,但显然它无法识别 TypeScript 变量声明如果设置了类型:

 C:\>deno
Deno 1.0.5
exit using ctrl+d or close()
> let x: number;
Uncaught SyntaxError: Unexpected token ':'
at evaluate ($deno$/repl.ts:54:34)
at Object.replLoop ($deno$/repl.ts:156:13)
> let x: number = 42;
Uncaught SyntaxError: Unexpected token ':'
at evaluate ($deno$/repl.ts:54:34)
at Object.replLoop ($deno$/repl.ts:156:13)
> let x = 42;
undefined
> x
42

我需要做一些特别的事情来让 Deno CLI 支持 TypeScript 吗?

最佳答案

Deno REPL 还不支持 typescript。

请参阅以下旧问题:https://github.com/denoland/deno/issues/1158这仍然是开放的。

Ryan Dahl 对 PR 的评论增加了 TS 支持:

2020 年 2 月 24 日

Just a bit more context for future researchers: There are many things we can do to improve the REPL without introducing the TS compiler. We should do those things first (e.g. improve inspect, tab completion). Once we're on par with Node's REPL, we can start looking into how to go beyond that by using typescript.

关于typescript - Deno REPL 无法识别 TypeScript 变量声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62212622/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com