使 complierOptions 在 tsconfig 中生成警告而不是错误
Make complierOptions generate warnings instead of errors in tsconfig
有没有办法在 tsconfig.json 文件中将选项 noUnusedLocals 和 noUnusedParameters 指示为警告而不是阻止编译的错误?
目前我在 tsconfig.json 文件中这样使用它们:
"compilerOptions": {
"noUnusedLocals": true,
"noUnusedParameters": true
},
我试过这个选项:
"no-unused-variable":正确,
在 tslint.json 文件中,但它没有检测到类似 tsc 的错误,并且在 visual studio 代码中我看不到它们带有下划线。
如您所见,Visual Studio 代码有一个 hack,可以在实时编辑期间将 noUnusedLocals 和 noUnusedParameters 问题显示为警告(typescript.reportStyleChecksAsWarnings
设置,默认为 true)。 tslint 扩展根本不显示这些问题,因为它们需要类型信息,the tslint extension does not support.
如果问题是您正在使用 tsc --noEmitOnError
之类的东西并且您不希望 noUnusedLocals/noUnusedParameters 错误阻止发射,那么您可以让 Visual Studio 代码使用一个 tsconfig.json
启用了 noUnusedLocals/noUnusedParameters 并让你的命令行构建使用 tsc
和一个单独的 tsconfig.json
禁用了选项,加上 tslint
和 no-unused-variable .
有没有办法在 tsconfig.json 文件中将选项 noUnusedLocals 和 noUnusedParameters 指示为警告而不是阻止编译的错误?
目前我在 tsconfig.json 文件中这样使用它们:
"compilerOptions": {
"noUnusedLocals": true,
"noUnusedParameters": true
},
我试过这个选项:
"no-unused-variable":正确,
在 tslint.json 文件中,但它没有检测到类似 tsc 的错误,并且在 visual studio 代码中我看不到它们带有下划线。
如您所见,Visual Studio 代码有一个 hack,可以在实时编辑期间将 noUnusedLocals 和 noUnusedParameters 问题显示为警告(typescript.reportStyleChecksAsWarnings
设置,默认为 true)。 tslint 扩展根本不显示这些问题,因为它们需要类型信息,the tslint extension does not support.
如果问题是您正在使用 tsc --noEmitOnError
之类的东西并且您不希望 noUnusedLocals/noUnusedParameters 错误阻止发射,那么您可以让 Visual Studio 代码使用一个 tsconfig.json
启用了 noUnusedLocals/noUnusedParameters 并让你的命令行构建使用 tsc
和一个单独的 tsconfig.json
禁用了选项,加上 tslint
和 no-unused-variable .