Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 807
Nathan Thibert Avatar asked Jun 27 '18 18:06

Nathan Thibert


People also ask

How do I disable TypeScript errors in VSCode?

In the Extensions tab on the left (Ctrl+Shift+X), search for @builtin + JavaScript / TypeScript . Then click the little gear icon next to an Extension and click Disable .

How do I disable TS errors?

Use the // @ts-ignore comment to disable type checking for a line in TypeScript. The comment disables type checking for the next line. If you use a linter, you might need to disable it for the line on which you use the // @ts-ignore comment. Copied!

What is TS file in VSCode?

TypeScript is a typed superset of JavaScript that transpiles to plain JavaScript.


2 Answers

On Windows- File > Preferences > Settings Go to Extensions->TypeScript-> Javascript>Validate make sure Enable/disable JavaScript validation. is not checked

enter image description here

like image 36
BenE Avatar answered Sep 25 '22 10:09

BenE


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.

like image 144
Kirk Larkin Avatar answered Sep 26 '22 10:09

Kirk Larkin