Checks and troubleshooting
How to see the configuration TypeScript computes, run the type-check, compare your copy, and read common errors.
@workspace/typescript-config 1.0.0Developmentunreleased, maintained in Foundation as a copy
See the effective configuration#
Print what TypeScript computes from the three layers, in the folder of the tsconfig.json:
pnpm exec tsc --showConfigFor a package on nodejs.json with only include and exclude of its own, the compiler options
read (followed by files, include and exclude; TypeScript may add options it derives, such as
preserveConstEnums):
{ "compilerOptions": { "declaration": true, "declarationMap": true, "esModuleInterop": true, "incremental": false, "isolatedModules": true, "lib": ["es2022", "esnext.temporal"], "module": "esnext", "moduleDetection": "force", "moduleResolution": "bundler", "noUncheckedIndexedAccess": true, "resolveJsonModule": true, "skipLibCheck": true, "strict": true, "target": "es2022", "types": ["node"], "noEmit": true }}Check there that strict and noUncheckedIndexedAccess arrive, that lib, types and jsx are
those of the preset you meant, and, under files, which files the project holds. To see why a file
is part of the project, add --explainFiles to a type-check.
Run the type-check#
pnpm exec tsc --noEmit| Result | Exit code |
|---|---|
| no type errors | 0 |
| one type error or more | 2 |
There is no threshold: unlike lint, a single error fails the run. Which packages are checked, and
by which root script, is your repository's choice, for example turbo typecheck --continue or
pnpm -r --no-bail typecheck.
Check your copy#
The package arrives as a copy, so no applier checks it. Compare it with Foundation's state:
diff -rq -x node_modules -x .turbo <foundation>/packages/typescript-config packages/typescript-configNo output means equal. Any difference is either a newer state in Foundation, to take over as a whole, or a local edit, which is a defect to undo.
Common errors#
| Error | Cause and remedy |
|---|---|
TS6053: File '@workspace/ | the package is not declared at the root, not installed, or the file name is wrong: one of nodejs., react-, nextjs. |
TS2532: Object is possibly 'undefined' on values[0] | no: check the element, or use values[0] ?? fallback |
TS2584: Cannot find name 'document' | DOM code under nodejs.; if the package really runs in a browser, it needs react- |
TS6142: Module '…' was resolved to '…. | the type-check reaches a . file of a dependency; use react- (Presets) |
TS2591: Cannot find name 'process' | no Node types: add "types": ["node"] (with @types/ installed), keeping any types the preset had |
TS7026: JSX element implicitly has type 'any' in a Next.js app | next- is missing from include, or next is not installed in the app |