关于tslint:TypeScript linter警告:不推荐使用no-unused-variable; 但我没有使用此配置

TypeScript linter warning: no-unused-variable is deprecated; but I'm not using this config

今天,我在3个月后刷新的项目中看到此警告。

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

但是我的tsconfig.json似乎没有使用它。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
 "compilerOptions": {
   "lib": ["es6"],
   "module":"commonjs",
   "noImplicitReturns": true,
   "outDir":"lib",
   "sourceMap": true,
   "target":"es6",
   "allowJs" : true
  },
 "compileOnSave": true,
 "include": [
   "src"
  ]
}

可能是任何先前配置中都隐含的配置。

您能指出我该怎么做吗?

如果有用

1
2
3
4
$ node -v
v10.3.0
$ npm -v
6.1.0

这些是devDependencies与我的package.json中的类型脚本有关

1
2
3
4
5
6
"devDependencies": {
    ...
   "tslint":"^5.11.0",
   "typescript":"^2.9.1"
    ...
  },


就像上面说的那样,tslint不赞成使用该规则(更多信息请参见https://github.com/palantir/tslint/pull/3919)

检查您的tslint.json,并删除规则,警告应消失。


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

  • 从您的或依赖项中删除不推荐使用的no-unused-variable
    tslint.json
    文件。

  • 在您的计算机中指定以下编译器选项
    tsconfig.json
    文件。

  • 1
    2
    3
    4
    "compilerOptions": {
     "noUnusedLocals": true,                /* Report errors on unused locals. */
     "noUnusedParameters": true             /* Report errors on unused parameters. */
    }

    不仅支持no-unused-variable规则,而且不赞成使用整个TSLint,而赞成使用typescript-eslint。

    考虑迁移到新的lint。