• Error
  • Reported by the type checker

TS2304

Cannot find name '{0}'.

A name is used that isn't declared anywhere the checker can see: a typo, a missing import, or a missing type package such as @types/node.

What it means

The identifier doesn't resolve to any variable, function, class, type or namespace in scope, in the file's imports, or in the global declarations of the lib files and type packages the project includes.

Example

index.ts
export const total = subtotal + 1;
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(1,22): error TS2304: Cannot find name 'subtotal'.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • Fix the spelling, or declare the name.
  • Import it if it lives in another module.
  • For globals such as process or describe, install the type package (@types/node, your test framework's types) and check types in tsconfig.json.