Skip to content
Latchkey

tsc TS6133: 'x' is declared but its value is never read (noUnusedLocals) in CI

TS6133 reports an unused local variable, import, or parameter. With noUnusedLocals / noUnusedParameters enabled, tsc raises it as an error, so a harmless leftover binding fails the build in CI.

What this error means

tsc fails with "error TS6133: 'x' is declared but its value is never read." for an import or variable that is never used, often code that lints clean locally without these flags.

tsc
src/util.ts:1:10 - error TS6133: 'readFile' is declared but its value is never read.

1 import { readFile } from 'node:fs/promises';
           ~~~~~~~~

Common causes

An unused import or variable left after refactoring

A binding stayed behind when the code that used it was removed, and noUnusedLocals turns that into a hard error.

CI enables noUnusedLocals where the editor did not

The editor may not flag unused locals, so the leftover binding only fails when CI runs tsc with the stricter tsconfig.

How to fix it

Remove the unused binding

  1. Delete the unused import or variable named in the error.
  2. For a parameter you must keep, prefix it with _ so tsc ignores it.
  3. Re-run tsc to confirm TS6133 clears.
src/util.ts
// drop the unused import, or rename an unused param to _
function handler(_req: Request, res: Response) { res.end(); }

Keep the flag and let it gate dead code

Rather than disabling the option, treat TS6133 as a useful signal that removes dead imports before they accumulate.

tsconfig.json
{
  "compilerOptions": { "noUnusedLocals": true, "noUnusedParameters": true }
}

How to prevent it

  • Remove imports and locals as soon as they stop being used.
  • Prefix intentionally-unused parameters with _.
  • Run tsc with the CI tsconfig locally so these surface early.

Frequently asked questions

What causes "TS6133 "declared but its value is never read""?
A binding stayed behind when the code that used it was removed, and noUnusedLocals turns that into a hard error.
How do I fix TS6133 "declared but its value is never read"?
Remove the unused binding

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card