Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make complierOptions generate warnings instead of errors in tsconfig

Is there a way to indicate in the tsconfig.json file the options noUnusedLocals and noUnusedParameters as warnings instead of errors that block the compilation?

Currently I use them in the tsconfig.json file like this :

  "compilerOptions": {
    "noUnusedLocals": true,
    "noUnusedParameters": true
  },

I tried the option :

"no-unused-variable": true,

in the tslint.json file but it doesn't detect errors like the tsc, and in visual studio code I can't see them underlined.

like image 830
Brahim LAMJAGUAR Avatar asked Jul 30 '18 12:07

Brahim LAMJAGUAR


1 Answers

As you may have seen, Visual Studio Code has a hack to display noUnusedLocals and noUnusedParameters problems as warnings during live editing (the typescript.reportStyleChecksAsWarnings setting, which defaults to true). The tslint extension does not display these problems at all because they require type information, which the tslint extension does not support.

If the issue is that you are using something like tsc --noEmitOnError and you don't want noUnusedLocals/noUnusedParameters errors to block the emit, then you could have Visual Studio Code use one tsconfig.json that has noUnusedLocals/noUnusedParameters enabled and have your command line builds use tsc with a separate tsconfig.json that has the options disabled, plus tslint with no-unused-variable.

like image 52
Matt McCutchen Avatar answered Nov 08 '22 20:11

Matt McCutchen