47

Today I see this warning in a project being refreshed after 3 months.

no-unused-variable is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead.

But my tsconfig.json does not seem to use this.

{
  "compilerOptions": {
    "lib": ["es6"],
    "module": "commonjs",
    "noImplicitReturns": true,
    "outDir": "lib",
    "sourceMap": true,
    "target": "es6",
    "allowJs" : true
  },
  "compileOnSave": true,
  "include": [
    "src"
  ]
}

Probably it's a config implicit in any of the previous configs.

Could you point me to what to do to fix it?

If usefull

$ node -v
v10.3.0
$ npm -v
6.1.0

And these are devDependencies relates to type script in my package.json

"devDependencies": {
    ...
    "tslint": "^5.11.0",
    "typescript": "^2.9.1"
    ...
  },
Rakhat
  • 4,783
  • 4
  • 40
  • 50
realtebo
  • 23,922
  • 37
  • 112
  • 189

3 Answers3

69

no-unused-variable is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead.

  1. Remove deprecated no-unused-variable from your or dependency tslint.json file.

  2. Specify the following compiler options in your tsconfig.json file.

"compilerOptions": {
  "noUnusedLocals": true,                /* Report errors on unused locals. */
  "noUnusedParameters": true             /* Report errors on unused parameters. */
}
Appulus
  • 18,630
  • 11
  • 38
  • 46
am0wa
  • 7,724
  • 3
  • 38
  • 33
37

As it says, tslint deprecated that rule (more info here https://github.com/palantir/tslint/pull/3919)

Check your tslint.json, and remove the rule and the warning should disappear.

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
Diego Pedro
  • 500
  • 4
  • 9
9

Not only support for no-unused-variable rule, but the whole TSLint has been deprecated in favor of typescript-eslint.

Consider migration to new linter.

Islam Murtazaev
  • 1,488
  • 2
  • 17
  • 27
  • 3
    Note that at the time of writing of this comment, Angular is still uses TSLint by default. The migration for Angular is still in progress. So Angular users might still want to stick TSlint for a short while until the Angular team is done with migrating. – Edwin Stoteler Nov 12 '20 at 11:37