typescript
lint_error
ai_generated
true
error TS6133: 'x' is declared but its value is never read
ID: typescript/ts6133-declared-not-read
98%Fix Rate
95%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 5 | active | — | — | — |
Root Cause
Unused variable or import. TypeScript reports this when noUnusedLocals/noUnusedParameters is enabled.
genericWorkarounds
-
98% success Remove the unused variable or import
// Remove the unused variable/import: // import { unused } from './module'; // delete this line // Or prefix with _ if intentionally unused: const _intentionallyUnused = getValue(); // In tsconfig.json, this is controlled by: // "noUnusedLocals": true, // "noUnusedParameters": trueSources: https://www.typescriptlang.org/tsconfig/#noUnusedLocals
-
92% success Prefix with underscore if intentionally unused: _unusedParam
function handler(_req: Request, res: Response) { ... }Sources: https://www.typescriptlang.org/tsconfig/#noUnusedParameters
Dead Ends
Common approaches that don't work:
-
Disable noUnusedLocals in tsconfig
65% fail
Disables a useful lint rule across the entire project
-
Assign to void: void unusedVar
70% fail
Obscure and confusing — just remove or prefix with underscore
Error Chain
Frequently confused with: