如何激活类型的打字稿验证?
我正在尝试遵循一个教程,其中预计该代码样本将失败。但是在我的机器中,它可以正常工作。
// example.ts
let age: number;
age = 15;
console.log(age);
age = "foo";
console.log(age);
这就是我看到的:
$ deno run example.ts
15
foo
我希望它会用 ts2322 代码失败。
$ deno --version
deno 1.23.1 (release, x86_64-unknown-linux-gnu)
v8 10.4.132.8
typescript 4.7.2
有见地吗?
I'm trying to follow a tutorial in which this sample of code is expected to fail. But in my machine it works just fine.
// example.ts
let age: number;
age = 15;
console.log(age);
age = "foo";
console.log(age);
This is what I see:
$ deno run example.ts
15
foo
I expected it to fail with a TS2322 code instead.
$ deno --version
deno 1.23.1 (release, x86_64-unknown-linux-gnu)
v8 10.4.132.8
typescript 4.7.2
Any insights?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从v
1.23
开始,默认情况下,DENO执行该代码不会键入您的代码。您可以使用命令
deNo键入代码(无执行)键入代码检查
。您还可以使用- 检查
参数到deNo Run
之前键入代码。以下是一些使用您的示例.ts
模块的示例:Starting in v
1.23
, by default, Deno does not type-check your code when executing it.You can type-check your code (without executing it) using the command
deno check
. You can also type-check your code before execution by using the--check
argument todeno run
. Here are some examples using yourexample.ts
module: