- Error
- Reported by the type checker
TS2688
Cannot find type definition file for '{0}'.
A types entry or /// <reference types> names a package whose type definitions can't be found. Install it or remove the entry.
What it means
The name comes from the types option in tsconfig.json or a /// <reference types="..." /> comment, and no matching type definitions were found (usually in node_modules/@types).
Example
{
"compilerOptions": {
"strict": true,
"target": "es2022",
"module": "esnext",
"moduleResolution": "bundler",
"noEmit": true,
"types": [
"not-installed"
]
}
}
export const x = 1;
ts-r-check -p tsconfig.json --pretty false ts-r outputerror TS2688: Cannot find type definition file for 'not-installed'.
Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01.
How to fix
- Install the definitions, for example
npm i --save-dev @types/<name>. - Fix the spelling of the entry.
- Remove the entry if the project no longer uses that package.