Removing [ts] errors from JS files In VS Code

JavascriptTypescriptVisual Studio-Code

Javascript Problem Overview

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

Javascript Solutions

Solution 1 - Javascript

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.

Solution 2 - Javascript

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

enter image description here

Solution 3 - Javascript

This works for me

On Windows- File > Preferences > Settings

enter image description here

make sure validate is not enable

Solution 4 - Javascript

Make sure javascript.implicitProjectConfig.checkJs is false VSCode settings.

Solution 5 - Javascript

On the settings.json file add a line

"js/ts.implicitProjectConfig.checkJs": true,
"javascript.validate.enable": false, // => required

Solution 6 - Javascript

I don't have enough information about project setup and code, but it looks like you are trying to load .js files as typescript.

To use JavaScript files in Typescript projects you must enable allowJs flag, either in command line --allowJs or in the tsconfig.json as "allowJs": true.

But, if the .js files should not be part of the TS project but just are in the same directory tree, you need to review your exclude and include properties of tsconfig.json

Solution 7 - Javascript

On visual studio code File > Preferences > Settings Go to Extensions->TypeScript-> Javascript>Validate make sure Enable/disable JavaScript validatio

Solution 8 - Javascript

This worked for me too: File > Preferences > Settings > Extensions->TypeScript-> Javascript>Validate make sure Enable/disable JavaScript validation. is not checked Thank you @BenE :)

Solution 9 - Javascript

Open settings in your VSC.
To open your user and workspace settings, use the following VS Code menu command:

  • On Windows/Linux - File > Preferences > Settings

  • On macOS - Code > Preferences > Settings
    Check if tslint.jsEnable is set to false

    // Control whether tslint is enabled for JavaScript files or not.
    "tslint.jsEnable": false,

Set it to false in workspace settings section

From the documentation:
tslint.enable - enable/disable tslint.
tslint.jsEnable - enable/disable tslint for .js files, default is false.

enter image description here


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNathan ThibertView Question on Stackoverflow
Solution 1 - JavascriptKirk LarkinView Answer on Stackoverflow
Solution 2 - JavascriptBenEView Answer on Stackoverflow
Solution 3 - JavascriptMD SHAYONView Answer on Stackoverflow
Solution 4 - JavascriptEbuallView Answer on Stackoverflow
Solution 5 - JavascriptTấn NguyễnView Answer on Stackoverflow
Solution 6 - JavascriptJaan OrasView Answer on Stackoverflow
Solution 7 - JavascriptjamesView Answer on Stackoverflow
Solution 8 - JavascriptZakaria MoslimView Answer on Stackoverflow
Solution 9 - JavascriptAvinashView Answer on Stackoverflow