88

So this feels like this should be such an easy task but it's starting to drive me insane. I can't seem to turn off TSLint or TS or whatever it is that gives me these errors. I just want the ESLint with my own configured rules, nothing else.

I only want the ESLint error

Is it built in TS? I have disabled TSLint extension (even uninstalled it). I have set the following rules:

"typescript.format.enable": false,
"typescript.validate.enable": false,

Still gives me error. How do I turn this off?

Henrik Andersson
  • 45,354
  • 16
  • 98
  • 92
Clanket
  • 1,259
  • 2
  • 11
  • 16
  • you could try doing `/*tslint:disabled*/` after the line. If that doesn't work then it might be your IDE that is throwing the error/warning saying you are doing something wrong. It says you are never using CircleSpinner so are you using it in your html and bypassing the typescript? You may be able to add it to the constructor or something and it will go away. – rhavelka Jun 12 '18 at 21:03
  • 7
    Did you restart the editor after you made changes to your settings? Setting `"typescript.validate.enable": false,` made my `[ts]` checks go away. – Henrik Andersson Jun 12 '18 at 21:05
  • @HenrikAndersson Actually it doesn't seem to work. It keeps coming back. I have that rule set to false already and I tried reloading and restarting. Same issue still :( – Clanket Jun 20 '18 at 17:52
  • 1
    @rhavelka It works but as far as I'm concerned it really doesn't solve anything. I don't want a fix, but rather a proper solution. – Clanket Jun 20 '18 at 17:54
  • 11
    It's not working. It drives me crazy. – Bright Lee Jul 23 '18 at 22:09
  • Note: maybe this will change with 1.42? (https://stackoverflow.com/a/59972718/6309) – VonC Jan 29 '20 at 18:18
  • It does not work for me either. I open a new question https://stackoverflow.com/questions/73233144/skip-tslint-alert-in-angular – Ulises 2010 Aug 08 '22 at 09:49

8 Answers8

102

It seems that the error is coming from the TypeScript extension, which is also handling the JavaScript IntelliSense. Due to some UX ignorance, VSCode prefixes the error with [ts] instead of [js].

To disable these validations, set

"javascript.validate.enable": false

See this issue for more details.

user3151902
  • 3,154
  • 1
  • 19
  • 32
  • 9
    This is the correct solution. The files are JS so it's "Javascript validation". But this validation is done via the underlying Typescript engine. Could be a bit confusing. IMO ESLint suffices especially for older projects where the TS engine will throw tons of errors without an obvious way to configure. – xji Sep 11 '18 at 14:13
27

I've been hunting around for this answer for the better part of a month now. I found a solution that works in VS Code that isn't a wholesale disabling of all validation for javascript and also did not require that I add files/declarations to a repository that is not mine.

Add this line to your user settings:

"javascript.suggestionActions.enabled": false

Unlike "javascript.validate.enable": false (which you should not use), the above setting will remove those annoying [ts] Could not find a declaration file for module errors for untyped module imports in javascript files and it will still play nice with linters and give you appropriate and relevant errors.

Bita Djaghouri
  • 371
  • 3
  • 4
  • 1
    Exactly! We don't want to disable errors, just "warnings" - in my case, it was pestering me incessantly that it could have inferred better types for _JavaScript_ code?!? If I wanted types (and I do, but can't use them in this project) I would have used TypeScript... thanks for this! – rawpower Jan 08 '19 at 17:01
  • @rawpower,@Morrel, I thinks you guys are wrong, the OP already has esLint activated and wants to remove both the TSLint errors and warnings. – Hugo Cantacuzene Mar 08 '19 at 18:28
  • @HugoCantacuzene This solution will actually be the only one that doesn't effect eslint! The other solutions will disable linters. This one will prevent TS lint from trying to validate JS. :) – Bita Djaghouri Apr 04 '19 at 12:40
  • 1
    I don't know why but this not works for me . "javascript.validate.enable": false works but as you mentioned I don't want disabled all nalidations. – Shinji035 Mar 03 '20 at 03:53
13

Ctrl-Shift-P (Command Palette)

Type Preferences: Open Workspace Settings JSON

add

"tslint.enable":false

Or

"typescript.validate.enable": false

But beware, as @rawpower has said "We don't want to disable errors, just 'warnings'"

Anyways, save and restart VSCode

Buddy Bob
  • 5,829
  • 1
  • 13
  • 44
Piero
  • 1,638
  • 1
  • 13
  • 14
  • 6
    even after disabling typescript validate and tslint in VSCode I still see ts error messages: `"typescript.validate.enable": false,` `"tslint.enable": false,` `"tslint.jsEnable": false` – Paul Aug 07 '18 at 07:53
  • That's very strange. Must be something else going on - maybe bad `settings.json` file or in wrong location? – CodeFinity Jun 25 '21 at 13:21
  • For mine, I had `[ts]` showing up. So, I had to just add: `"typescript.validate.enable": false,`. Immediately, it went away. – CodeFinity Jun 25 '21 at 13:22
11

Most of the answers turn off the duplicate errors for JavaScript, not TypeScript, like the OP asked about. What worked for me was:

  1. Uninstall the TSLint vscode extension
  2. Install the ESLint vscode extension
  3. Finish configuring ESLint for TypeScript (will now have both "ts errors" and "eslint errors" at this point like the OP).
  4. Open settings.json and add this to the bottom: "typescript.validate.enable": false

At first, I was concerned that this option would turn off all typescript validation, including eslint, but fortunately that wasn't the case. It only disables the built-in vscode typescript validation and leaves eslint alone.

The most important part is adding "typescript.validate.enable": false to settings.json

Or, instead of manually editing settings.json, another way is to uncheck the box in the settings menu (ctrl+'):

vscode settings view to disable typescript validation

FYI, you can add it to either your User settings.json (applies to all your projects) or your Workspace settings.json (only applies to the current project).

RcoderNY
  • 1,204
  • 2
  • 16
  • 23
2

Just open settings (File -> preference -> Settings) or short cut (Ctl + ,) and search for the 'Javascript Validate'.

enter image description here

Rajesh
  • 4,273
  • 1
  • 32
  • 33
2

As far as I understand, VSCode is checking himself the javascript, and believe the TypeScript errors are what you expect.

To stop VSCode from checking my code, and let only the eslint extension check it, I did:

  • use eslint to check my javascript (install the extension)
  • tell vscode not to check my javascript files: in jsconfig.json:
{
   "compilerOptions": {
      "checkJs": false
   }
}

I still see the "eslint" reported errors, and those errors are coherent with command line run of eslint.

PS: jsconfig reference here: https://code.visualstudio.com/docs/languages/jsconfig

jehon
  • 1,404
  • 15
  • 21
1

For me the solution was to create a jsconfig.json file at root level. Inside you can configure the compilerOptions, which did the trick for me after restart of VSCode.

fmi21
  • 485
  • 3
  • 15
0

In VSCode User settings.json, I changed js/ts.implicitProjectConfig.checkJs from true to false

// settings.json
{
    "js/ts.implicitProjectConfig.checkJs": false
}
jared
  • 58
  • 6