Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
126 views
in Technique[技术] by (71.8m points)

javascript - Removing [ts] errors from JS files In VS Code

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

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...