101

I don't use TypeScript for the time being. Only ES6 with babel.
I don't have installed TypeScript in node_modules.

I get a specific warning from VSCode every time I open a workspace.

\node_modules\typescript\lib doesn't point to a valid tsserver install. Falling back to bundled TypeScript version.

How can I get rid of such warnings? Or should I change editor in order to feel calm?

Cedric Druck
  • 1,032
  • 7
  • 20
stefan2410
  • 1,931
  • 2
  • 16
  • 21
  • I am still getting ts6133 no-unused-vars, even though I have `// eslint-disable-line`. vscode removes the line on save. I have eslint and eslint vscode extension. I do not have tslint extension. My user settings: ``` "eslint.codeActionsOnSave.mode": "all", "breadcrumbs.enabled": true, "javascript.validate.enable": false, "typescript.validate.enable": false, "javascript.format.enable": false, "typescript.format.enable": false, "javascript.implicitProjectConfig.checkJs": false, "javascript.suggestionActions.enabled": false, ``` Please help! – barakbd Jan 25 '20 at 01:06
  • **Note:** Depending on what you're wanting, you may want to just disable the built-in Extensions altogether. See [my new answer](https://stackoverflow.com/a/68146666/1599699) for more. – Andrew Jun 26 '21 at 22:27

7 Answers7

188

TypeScript and JavaScript validation can be turned off in VS Code with these two settings:

"typescript.validate.enable": false,
"javascript.validate.enable": false,
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Johannes Rieken
  • 3,401
  • 1
  • 17
  • 10
  • 6
    Thanks, after your answer, I changed this setting and others for TypeScript, but the specific warning is not disappeared. I think the only way is to install in local node_modules the TypeScript. I can do it, even if I don't use it, but I am afraid not having other warnings later :-) – stefan2410 Mar 06 '17 at 19:14
  • Actually, that might a different problem. Some AV software deletes the `tsserver.js` file that we launch to provide features like formatting et al – Johannes Rieken Mar 08 '17 at 09:40
  • It looks for the \node_modules\typescript\lib, but I did not install the typescript. so there is not such folder. – stefan2410 Mar 08 '17 at 13:25
  • 9
    @JohannesRieken Why both? Aren't we only interested in disabling TypeScript? You can improve your solution by mentioning what the second statement does, it's pretty confusing given it states to disable JavaScript validation, when we are interested in disabling TypeScript. – Lemuel Uhuru Nov 18 '18 at 20:55
  • 9
    For some reason, I had to disable javascript validation to disable the typescript validation. That is very confusing. – Chris Dec 07 '18 at 17:45
  • 8
    It's a shame to disable builtin JS+TypeScript validation globally for all and any proiject (even TypeScript ones) just because it cannot be turned off on a 'per project' basis or isn't smart enough to not typescript validate non-typescript files. – simbolo Feb 07 '19 at 15:19
  • 4
    Where do you put these values? – Kingamere Mar 08 '19 at 20:00
  • 1
    @Kingamere file > preferences > settings > (top right) show as json – MadMax Dec 06 '19 at 19:40
  • 2
    @simbolo There is no need to turn it off globally for all projects. You can set it just for a single folder/project by creating a `.vscode` directory and adding a `settings.json` file inside of it. If you use a multi-root workspace you open the command palette and search for "workspace settings" and you will notice a separate settings menu item, apart from user settings. – Cory Gross Aug 12 '20 at 07:26
  • Some info about why `javascript.validate.enable: false` here: https://stackoverflow.com/a/52568994/5820158 – Lindsay-Needs-Sleep Nov 12 '20 at 00:27
  • This answer disables errors as well along with warnings which may not be the required case – Muhammad Awais Dec 13 '20 at 08:07
  • 1
    Downvoted as there must be a way to disable ONLY typescript but not the JavaScript warning/errors. Using only the `"typescript.validate.enable": false` option will still show in the editor warnings with `ts(...)` error codes – Gabriel Petrovay May 14 '21 at 12:39
  • 1
    @GabrielPetrovay vscode uses the typescript language server to validate javascript, so "javascript.validate.enable" requires typescript to function. It should be using the built in version of typescript if the project doesn't have a dependency on typescript, so this error is most likely caused by a workspace or user preference that sets the tsc or tsdk path. It's usually from setting the tsc path in the global preferences instead of workspace preferences when working on another project. – Parker Ault Jun 23 '21 at 18:05
  • I never have luck finding this in the preferences when my workspace settings get wiped after I run `git-clean` and always have to come here ':)! – Filip Dupanović Feb 22 '22 at 15:46
  • When adding javascript.validate.enable: false ts errors goes away but it also removes the auto import suggestion in the "Quick fix..." - Adding a jsconfig.json didn't solve the auto import issue neither. This must be a bug imo – iji Aug 31 '22 at 19:27
38
  1. open the command palette : CTRL + SHIFT + P

  2. open the file settings.json :

enter image description here

  1. add these 2 lines of code:

    "typescript.validate.enable": false,
    "javascript.validate.enable": false,
    
marcdahan
  • 2,654
  • 25
  • 25
  • This error is almost always caused by accidentally setting the path to the typescript compiler or tsdk library in the user preferences instead of the workspace preferences when working on a typescript project, then switching to a javascript project. If anyone reading this has this problem, try Bernard's answer first and only disable validation if it doesn't work. You probably want to know if your javascript is buggy. :) – Parker Ault Jun 23 '21 at 18:09
14

I was having a similar problem. I had an incorrect setting for typescript.tsdk in my user settings:

"typescript.tsdk": null

To fix it, you can either set the location to a valid location:

"typescript.tsdk": "/usr/local/lib/node_modules/typescript/lib",

or just remove the line from your settings if are not using Typescript.

If you need more detail, I found the VSCode docs to be very concise and easy to understand.

Bernard Leech
  • 756
  • 7
  • 14
  • 3
    This is the correct answer. It's too bad a bunch of people will see the accepted answer and turn off their validation instead. – Parker Ault Jun 23 '21 at 18:10
13

As per here, you can disable built-in extensions in VSCode now. 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.

I disabled TypeScript and JavaScript Language Features (there is a JavaScript Language Basics Extension) and TypeScript Language Basics.

Andrew
  • 5,839
  • 1
  • 51
  • 72
  • 1
    I tried this also, but it also disabled the TS definition files and import navigation, which I did not want turned off. – Mike Young Jul 29 '21 at 04:07
7

In my case it was caused because there was extension that used vscode.typescript-language-features extension.

I still wanted javascript errors to be shown so "javascript.validate.enable": false, wasn't an option.

By disabling the extension "VueDX" that was using the @builtin extension it fixed the issue and still shows javascript syntax errors.

You can search all the typescript extensions by searching on @builtin typescript

Guus
  • 71
  • 1
  • 2
2

If you want to modify a setting, open the settings option (there is a new settings editor by the time I am writing this) and search for the setting you want to modify. I was attempting to change the typescript validation, but I wasn't allowed as the document was read only. If you hover over the setting, you get a pen on the left of the setting. If you right click on the pen, it will give you the option of true or false, as for my case I was targeting "typescript.validate.enable". I changed it to false, which in turn, VS code copied the code into the right of the screen with the new value. In short, the left is the settings.json file. On the right, you have the user-settings.json. You are only allowed to modify the user settings and the user setting can override any settings in the main settings.json file. -Kf

enter image description here

K F
  • 1,368
  • 13
  • 20
0

Good answers, but I had a situation where I only wanted to turn off TypeScript validation for some unported vanilla JavaScript that we're using in TypeScript land. Our use of eslint didn't catch nearly as many errors as the TypeScript validator, so to preserve the ability to validate "real" *.ts, it was important to only turn off TypeScript validation for specific files.

Easy enough, it turns out. From bobbyhadz.com:

Use the // @ts-nocheck comment to disable type checking for an entire file in TypeScript.

...

// @ts-nocheck

console.log('no errors' / 0);
console.log('no errors' / 0);

And from the TypeScript docs (which shows ways to get even more granular):

You can skip checking some files by adding a // @ts-nocheck comment to files.

TypeScript may offer you errors which you disagree with, in those cases you can ignore errors on specific lines by adding // @ts-ignore or // @ts-expect-error on the preceding line.

// @ts-check
/** @type {number} */
var x;
 
x = 0; // OK
// @ts-expect-error
x = false; // Not OK
ruffin
  • 16,507
  • 9
  • 88
  • 138