问题描述
限时送ChatGPT账号..我在处理 JS 文件时遇到了这些 TypeScript 错误 VS Code.我能做些什么来禁用它吗?我已经把它放在我的设置中,但没有解决问题:
"typescript.validate.enable": false
错误可以在这里看到
解决方案GitHub 问题
a> 更详细地讨论了错误中的 [ts]
标记.与此讨论最相关的评论是:
是的.TypeScript 扩展为我们的 javascript 智能感知提供支持,这就是您在 js 文件中看到 [TS]
的原因.这仅表明哪个扩展程序提供了该错误.
您可以通过将以下内容添加到适当的 settings.json
文件来禁用此验证本身:
"javascript.validate.enable": false
docs 进一步讨论了这个选项:
<块引用>使用 javascript.validate.enable: false
,您可以禁用所有内置语法检查.如果您这样做,我们建议您使用像 ESLint 这样的 linter 来验证您的源代码.
如上所述,这会禁用所有内置语法检查.虽然建议使用类似 ESLint 之类的东西,但如果您特别关注import
/export
错误.您可以将 jsconfig.json
文件添加到您的项目中,内容如下:
{编译器选项":{模块":es2015"}}
这指示 VS Code 使用 es2015 模块语法(import
/export
),这似乎使它更快乐.
I get these TypeScript errors VS Code while I'm working in JS files. Is there anything I can do to disable this? I have put this in my settings and did not solve the issue:
"typescript.validate.enable": false
The error can been seen here
解决方案There's a GitHub issue that discusses the [ts]
token from the errors in a bit more detail. The most relevant comment to this discussion is:
Yes. The TypeScript extension powers our javascript intellisense which is why you see
[TS]
in your js file. That only indicates what extension is providing that error.
You can disable this validation itself by adding the following to an appropriate settings.json
file:
"javascript.validate.enable": false
The docs discusses this option a little bit further:
With
javascript.validate.enable: false
, you disable all built-in syntax checking. If you do this, we recommend that you use a linter like ESLint to validate your source code.
As noted above, this disables all built-in syntax checking. Although the suggestion is to use something like ESLint instead, there might be another option if you're specifically concerned about the import
/export
errors. You can add a jsconfig.json
file to your project with the following content:
{
"compilerOptions": {
"module": "es2015"
}
}
This instructs VS Code to use the es2015 module syntax (import
/export
), which appears to make it happier.
这篇关于在 VS Code 中从 JS 文件中删除 [ts] 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论