• Error
  • Reported by the type checker

TS2552

Cannot find name '{0}'. Did you mean '{1}'?

A name that isn't declared is used, and a similarly named one is in scope. Usually a typo: use the suggested name.

What it means

This is TS2304 with a suggestion: no variable, function or type with this name is in scope, but one with a close spelling is.

Example

index.ts
const userName = "ada";
export const greeting = "hi " + username;
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(2,33): error TS2552: Cannot find name 'username'. Did you mean 'userName'?

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

  • Use the suggested name if it's what you meant.
  • Otherwise declare or import the name.