当模块存在时,为什么 VS Code 会抛出“找不到模块 'typescript'.ts(2307)”?

Tom*_*Tom 1 node.js node-modules typescript visual-studio-code

我用来import * as ts from "typescript";在 .ts 文件中导入打字稿。

该文件运行良好,但 VS Code 告诉我Cannot find module 'typescript'. ts(2307)

有什么办法可以抑制这个问题吗?

编辑:文件可以成功编译并运行

Sad*_*ddy 8

您想要更改 VS Code 的 settings.json 中的这两个设置:

"typescript.validate.enable": false,
"javascript.validate.enable": false,
Run Code Online (Sandbox Code Playgroud)

来源