useTypeScriptCli
Run the project-local TypeScript CLI for type checking during production builds.
By default, next build runs the project-local tsc command instead of loading the TypeScript JavaScript compiler API. This supports TypeScript 6 and enables TypeScript 7 while its JavaScript API is unavailable.
Install TypeScript 7 in your project:
The CLI checker is enabled by default. To use the TypeScript JavaScript compiler API instead, set experimental.useTypeScriptCli to false:
If you opt out while using TypeScript 7, next build exits because the TypeScript JavaScript compiler API is unavailable.
Behavior
- Next.js continues to generate
next-env.d.tsand route types and to apply its recommendedtsconfigsettings before running the checker. - TypeScript diagnostics are printed directly from
tsc. Next.js-specific code frames and error rewriting are not applied. - The complete project selected by the configured
tsconfigfile is checked, including test files and.next/dev/typeswhen included. The--debug-build-pathsoption does not limit this set and produces a warning when combined with the CLI checker. typescript.tsconfigPathselects the project passed totsc.typescript.ignoreBuildErrorsskips the type-checking step, including the CLI checker.
Learn more about using TypeScript 7 with Next.js.