TypeScript Reference ยท tsconfig: Type Checking Options
TypeScript noUnusedParameters option
Reference for noUnusedParameters: error TS6133 for function parameters that are never read, the underscore prefix, callbacks, and parameter ordering.
noUnusedParameters reports an error when a function parameter is never read inside the function body. An unused parameter usually means a signature that has drifted from its implementation: the function no longer needs the data, but every caller still passes it.
Parameters whose names start with an underscore are exempt, which is the standard way to say "required by the signature, intentionally ignored". The option is not part of strict. A sibling option, noUnusedLocals, covers variables and imports.
function add(a: number, b: number, _debug: boolean): number { return a + b; // _debug is allowed to stay unused }
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.
Syntax
{ "compilerOptions": { "noUnusedParameters": true } }
| Part | Description |
|---|---|
| Value | true or false. Default: false. Not included in strict. |
| Error | TS6133: 'x' is declared but its value is never read. |
| Exempt | Parameters beginning with _, the this pseudo-parameter, and parameters in declarations without bodies (overload signatures, abstract methods, declare function, interfaces). |
| Related | Rest parameters and destructured parameters are checked like any other binding. |
Usage notes
- Only trailing parameters can be dropped. If a callback needs the second argument but not the first, name the first
_(or_first); you cannot skip a position. - Overrides that ignore a base-class argument also use the underscore.
- Constructors with parameter properties (
constructor(private name: string)) count as used, since the property is declared. - Type-only parameters: unused generic type parameters are reported by
noUnusedParameterswith the same code ('T' is declared but never used). - Public API stability. In libraries, removing a parameter can break callers, so keeping an underscore-named placeholder is sometimes deliberate.
- Interaction with
noImplicitAny. An unused parameter in a callback is still contextually typed from the receiving function.