noUnusedLocals reports local variables, functions and imports that are declared but never read; noUnusedParameters does the same for function parameters. Both use TS6133 ("is declared but its value is never read"). Exported names are not local, so they are never reported.
Neither is part of strict. Both arrived with TypeScript 2.0.
At a glance
| Write | Optional. Many projects leave both off and let a linter report unused names as warnings |
|---|---|
| On the command line | --noUnusedLocals |
| Type | boolean |
| Default in TypeScript 5.9 | false |
| TypeScript's description | Enable error reporting when local variables aren't read. |
The description is quoted from TypeScript's own option list (Apache-2.0); see the notices.
Examples
import { readFile } from "node:fs/promises";error TS6133: 'readFile' is declared but its value is never read.
/**
* @param {string} name
* @param {number} retries
* @param {unknown} _context
*/
export function greet(name, retries, _context) {error TS6133: 'retries' is declared but its value is never read.
const prefix = "Hello";error TS6133: 'prefix' is declared but its value is never read.
return `Hi, ${name}`;
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": [
"node"
],
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": [
"*.js"
]
} import { readFile } from "node:fs/promises";
/**
* @param {string} name
* @param {number} retries
* @param {unknown} _context
*/
export function greet(name, retries, _context) {
const prefix = "Hello";
return `Hi, ${name}`;
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": [
"node"
]
},
"include": [
"*.js"
]
} Keeping a parameter you do not use
A callback often has to accept a parameter it ignores. Start its name with an underscore, as _context does in the example, and noUnusedParameters leaves it alone.
Errors, not warnings
TypeScript reports these as errors, so npm run lint fails while you are halfway through a change and a variable is not used yet. That is why many teams leave both off and use a linter rule instead, which can be a warning. Bun's recommended config, for example, sets both to false.
Gotchas
- An import used only in a JSDoc type counts as used.
Sources
- TSConfig Reference: noUnusedLocals · TypeScript
- TSConfig Reference: noUnusedParameters · TypeScript
- TypeScript 2.0 release notes · TypeScript handbook
- TypeScript 2.6 release notes · TypeScript handbook
- TypeScript · Bun docs
Last reviewed 20 October 2026.