Reputation: 10030
While working on a TypeScript project, I commented out a line, and got the error:
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.
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.
Any way to disable or ignore that warning?
Upvotes: 74
Views: 67521
Reputation: 241
I had the same problem in my React App. Apart from changing the "noUsedLocals": false
property in the tsconfig.json
, you also need to adjust the "noUnusedParameters": false
. The former is only applicable to local variables, if you are passing unused parameters through functions, the latter will need to be changed to false as well.
In summary, you'll have to do the following:
{
"compilerOptions": {
"noUnusedLocals": false,
"noUnusedParameters": false,
}
}
Upvotes: 12
Reputation: 329
In tsconfig.json
{
"compilerOptions": {
...
"noUnusedLocals": false, // just set this attribute false
}
}
It will be done.
For more tips:
In xxx.ts file
//@ts-nocheck
when on the top of the file,it will not check the below.
//@ts-ignore
when use it,it will not check the next line
Upvotes: 20
Reputation: 40544
You probably have the noUnusedLocals
compiler option turned on in your tsconfig.json
. Just turn it off during development.
Upvotes: 108