typescript 忽略 TS6133:“(导入)已声明但从未使用过”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44565671/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ignore TS6133: "(import) is declared but never used"?
提问by jdm
While working on a TypeScript project, I commented out a line, and got the error:
在处理 TypeScript 项目时,我注释掉了一行,并得到了错误:
Failed to compile
./src/App.tsx (4,8): error TS6133: 'axios' is declared but never used.
This error occurred during the build time and cannot be dismissed.
编译失败
./src/App.tsx (4,8): error TS6133: 'axios' is declared but never used.
此错误发生在构建期间,无法消除。
The error is right, I am importing axios, but I wanted to temporarily comment out the call to axios.get
. I appreciate that error as it keeps my imports clean, but during early development is is pretty disruptive.
错误是对的,我在导入axios,但是我想暂时注释掉对axios.get
. 我很欣赏这个错误,因为它使我的导入保持干净,但在早期开发过程中是非常具有破坏性的。
Any way to disable or ignore that warning?
有什么方法可以禁用或忽略该警告?
回答by Saravana
You probably have the noUnusedLocals
compiler option turned on in your tsconfig.json
. Just turn it off during development.
您可能noUnusedLocals
在tsconfig.json
. 只需在开发过程中将其关闭即可。