Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

TS6133: 'value' is declared but its value is never read

noUnusedLocals and noUnusedParameters report TS6133 on dead bindings. Find which config enabled the flag, then fix locals, imports and parameters.

~5 min readTypeScript
#TypeScript#Compiler#Build#Refactoring
A TypeScript source sheet with an unused variable crate beside a cyan compiler gate, amber warning plate

Introduction & Quick Summary

error TS6133: 'value' is declared but its value is never read. is not a type error. It is noUnusedLocals or noUnusedParameters reporting that a binding was created and never referenced, and the compiler treats an unused binding as dead code worth failing the build over.

The four things that actually produce it:

  • A strict base config enabled it for you. "extends" pulls the flag from a shared preset, so it appears without anyone editing the project's own tsconfig.json.
  • Editor and CLI use different TypeScript versions, so one reports a clean file and the other fails in CI.
  • Only parameters starting with _ are exempt. value_, unusedValue, and ESLint disable comments do nothing for tsc.
  • Destructuring with a rest element is still reported. const { secret, ...rest } = config fails when secret is unused, because TypeScript has no ignoreRestSiblings.
DiagnosticReported forTypical triggerFix shape
TS6133Local, parameter, import bindingAny binding never readRemove it, _ prefix a parameter, or read it
TS6196Interface, type alias, enum never usedType-only dead codeDelete it or export it
TS6198Destructuring where every element is unusedconst { a, b } = x with nothing usedDrop the statement
TS6192An entire import declarationNeither imported name usedRemove the import
TS6138A private class memberDead private field or methodDelete the member

Core Mechanics, Signatures & Reproducible Setup

noUnusedLocals reports locals, imports, and unused type declarations. noUnusedParameters reports parameters of functions, methods, constructors, and arrows. Neither reports public or protected members, exported declarations, or anything addressed from outside the module, because the compiler cannot prove those unused across compilation units.

A reproducible failure needs two files:

{ "compilerOptions": { "target": "ES2022", "module": "NodeNext", "moduleResolution": "NodeNext", "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, "noEmit": true }, "include": ["src"] }
ts
// src/report.ts import { readFileSync, existsSync } from "node:fs"; export function loadReport(path: string, verbose: boolean): string { const prefix = "[report] "; const exists = existsSync(path); if (!exists) return prefix + "missing"; return prefix + readFileSync(path, "utf8"); }
text
src/report.ts:1:31 - error TS6133: 'existsSync' is declared but its value is never read. 1 import { readFileSync, existsSync } from "node:fs";

readFileSync and exists are read, so they pass. verbose is never read, so noUnusedParameters fails it too. The same file with both flags off compiles silently, which is why this appears after a config change rather than a code change. The flags are independent: fixing only locals leaves the parameter report in place.

Key Comparison Table

The report set decides where the build breaks and where an editor squiggle appears.

ToolUnused localsUnused paramsUnused private membersTemplate-only usage
tsc with noUnusedLocalsYesNoYes (TS6138)No, cannot see templates
tsc with noUnusedParametersNoYesNoNo
ESLint no-unused-varsYesYesNoWith a plugin parser
ESLint @typescript-eslint/no-unused-varsYesYes, with args: "after-used"NoWith a plugin parser

How to keep a binding without reading it depends on intent, and only some of these satisfy the compiler.

IntentTechniqueSilences TS6133Notes
Parameter required by a signature_verbose: booleanYesLeading underscore only
Deliberately discard an expressionvoid compute()YesReader-level intent is explicit
Value present only for rest collectionconst { secret, ...rest } = configNoTypeScript reports secret
Used by a decorator or frameworkexport const used = valueYesExporting makes it reachable
Used only in an SFC templatevue-tsc or svelte-checkn/aPlain tsc cannot see it

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

The leading underscore rule and where it stops

TypeScript exempts a parameter whose name begins with _. It does not exempt locals, so const _cache = build() still fails, and it does not exempt imports.

ts
// fails: locals are never exempt const _cache = new Map<string, number>(); // passes: parameter exemption export function render(node: unknown, _depth: number): string { return String(node); }

When a parameter exists only to satisfy a callback signature, the underscore communicates intent. When a local exists because half a refactor shipped, delete it.

Destructuring with a rest element

This is the case that surprises teams from ESLint, where ignoreRestSiblings: true is common and has no TypeScript equivalent.

ts
type Account = { id: string; token: string; plan: string }; export function publicAccount({ token, ...safe }: Account): Omit<Account, "token"> { return safe; // token is never read -> TS6133 }
ts
type Account = { id: string; token: string; plan: string }; export function publicAccount(input: Account): Omit<Account, "token"> { return { id: input.id, plan: input.plan }; } // acceptable when the shape is large: underscore the binding export function strip({ token: _token, ...safe }: Account) { return safe; }

The explicit projection is the readable fix: it names the fields a caller may see. The underscore form compiles too, since destructured parameters follow the parameter rule.

Private members, getters and read-only fields

TS6138 fires only for private members. A protected member is reported nowhere, because a subclass in another file could use it. A field that is written but never read still counts as unused: assignment is not a read.

ts
export class RateLimiter { private readonly windowMs = 60_000; private last = 0; // written below and read in the comparison constructor(private budget: number) {} allow(now: number): boolean { if (now - this.last > this.windowMs) this.last = now; return this.budget > 0; } }

Delete the comparison and TS6138 appears on the field declaration, not on the assignment.

verbatimModuleSyntax and type-only imports

With verbatimModuleSyntax: true, every import that survives to the emitted file must be a value import. A type imported without type is either an error or an unused binding, and the diagnostic is often TS6133 on the type name rather than a hint about syntax.

ts
// fails: the import is emitted, but only a type is used import { User } from "./types.js"; export function name(user: User): string { return user.name; }
ts
// passes: erased at emit import type { User } from "./types.js"; export function name(user: User): string { return user.name; }

Overloads and implementation signatures

An overload signature is not compiled, so only the implementation is checked. A parameter present to match an overload's arity but unused by the implementation fails, and renaming it in the overload does not help.

ts
export function parse(input: string): number; export function parse(input: string, radix: number): number; export function parse(input: string, radix: number): number { return Number.parseInt(input); // radix is never read -> TS6133 }
ts
export function parse(input: string, radix?: number): number { return radix === undefined ? Number(input) : Number.parseInt(input, radix); }

Using the parameter is usually a bug fix rather than a suppression: the overload promised the behaviour and the implementation ignored it.

Frameworks that read values indirectly

Template compilers and dependency injection read bindings in ways plain tsc cannot see, so a value used only from a Vue SFC or Angular template is reported as unused.

bash
npx vue-tsc --noEmit # checks SFC templates npx ng build # Angular reads template bindings npx tsc --noEmit # templates are invisible here

If the pipeline must stay on tsc, keep the unused-value check in the framework-aware tool and set noUnusedLocals to false for the plain type check, instead of sprinkling underscores through template-facing code.

Common Compilation/Runtime Mistakes & Version Gotchas

Assuming extends inherits nothing. It inherits noUnusedLocals, noUnusedParameters, strict, and paths, but not include, exclude, or files.

Turning the flag off instead of the dead code on. "noUnusedLocals": false compiles, but it also stops the compiler from finding genuinely dead branches after a refactor.

Using @ts-ignore on the report. These suppress type errors on the next line. TS6133 is reported on the binding, and @ts-expect-error becomes an error of its own once the dead code is removed.

Expecting ESLint's ignoreRestSiblings to apply. The two tools have separate exemption lists, so a file can pass ESLint and fail tsc in the same commit.

Believing void is a general suppressor. void value reads the value, so it compiles, but an unhandled rejection is still a runtime problem. Use it only for genuinely fire-and-forget results.

Version notes. Both flags exist since TypeScript 2.0 and are unchanged through 5.x. verbatimModuleSyntax arrived in 5.0 and replaced importsNotUsedAsValues; configs that still set the removed option fail to parse. TS6196 and TS6198 came with the 4.x diagnostic rework, so older compilers report the same dead code under TS6133. Next.js enables neither flag by default, so a sudden failure usually means a strict preset was added in the same PR.

Triage order: run tsc --showConfig to see which file enabled the flag, then split the report into parameters (underscore or use), imports (remove or import type), and locals (delete). When the list is long, dump it and scan the deduplicated names with the regex tester, and compare two resolved configs with the text diff.

Official references: noUnusedLocals and noUnusedParameters.

Official references

primary documentation

The TypeScript documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit TypeScript work — they run entirely in this browser tab, so nothing you paste leaves your device.

All TypeScript guides

More in TypeScript

All TypeScript guides

The guides filed next to this one in TypeScript, in library order.