error TS2552: Cannot find name 'subTotal'. Did you mean 'subtotal'? is TS2304 with a suggestion: nothing called subTotal is in scope, and a declared name differs only slightly. Mixed-up capitalization is the most common cause.
At run time the same line throws ReferenceError: subTotal is not defined, but only when that line runs, and a line in an error branch may never run in testing.
At a glance
| Code | TS2552 |
|---|---|
| Message | Cannot find name '{0}'. Did you mean '{1}'? |
| TypeScript's category | error |
| Listed under | Unknown names and members |
| Turned on by | No option: every checked file reports it |
| In .js files | Reported when the file is checked: checkJs in jsconfig.json, or // @ts-check at the top of the file |
The message is TypeScript's own text from its diagnostic messages file (Apache-2.0); {0} and {1} are filled in by tsc for each error.
What it looks like
/** @param {number} subtotal */
export function withTax(subtotal) {
const taxRate = 0.08;
return subTotal * (1 + taxRate);error TS2552: Cannot find name 'subTotal'. Did you mean 'subtotal'?
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} What causes it
- The name is misspelled or capitalized differently from its declaration.
- The name is declared in another scope (inside a different function or block) and a similar name is visible here.
How to fix it
Use the declared name
Accept the editor's Change spelling quick fix or correct the name by hand.
/** @param {number} subtotal */
export function withTax(subtotal) {
const taxRate = 0.08;
return subtotal * (1 + taxRate);
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} If the name is a real global, declare it
When the name you wrote is right and comes from a script tag or the environment, the suggestion is a coincidence; declare the global as shown on the TS2304 page.
Gotchas
- Lowercase
arrayandpromisein a JSDoc type are also reported as TS2552 understrict, withArrayandPromisesuggested; in JSDoc the type names are capitalized.
Sources
- Everyday Types · TypeScript handbook
- diagnosticMessages.json (TypeScript 5.9.3) · TypeScript on GitHub
Last reviewed 20 October 2026.