- Error
- Reported by the type checker
TS2503
Cannot find namespace '{0}'.
A qualified type name like A.B refers to a namespace that doesn't exist. Import the namespace or fix its name.
What it means
In a type position, Name.Member looks Name up as a namespace. When no namespace (or namespace import, or enum) with that name is in scope, it is reported. Missing @types packages that provide global namespaces such as NodeJS or React are a common cause.
Example
export let timer: Timers.Handle;
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(1,19): error TS2503: Cannot find namespace 'Timers'.
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 import the namespace:
import type * as Timers from "./timers". - For global namespaces from type packages, install the package and add it to
typesin tsconfig if you list them.