[Backport] Fixes to support TypeScript 7 (#95831)
Backports the TypeScript 7 support fixes to the `16.2.x` release line to
resolve #95801, where `next build` crashes with a silent
`SIGSEGV`/`SIGABRT` when `typescript@7` is installed (the legacy
TypeScript JavaScript API is unavailable in TS7).
Cherry-picks the following, in order:
- #92277 — Resolve `compilerOptions.paths` in tsconfigs without
`compilerOptions.baseUrl` (prerequisite; source change only)
- #95639 — (TypeScript 7 Support) Add experimental TypeScript CLI
backend
- #95692 — Fix termination handling
- #95753 — Better support the CLI spinner when running the TSC CLI
Together these add the opt-in `experimental.useTypeScriptCli` backend
(runs the project-local `tsc` during `next build`, supporting TS7),
preserve the TypeScript API backend as the default with actionable TS7
migration guidance instead of a crash, and fix worker termination and
CLI spinner handling.
## Prerequisite: #92277
The TypeScript CLI backend tests exercise a `paths` alias that is
inherited from an extended tsconfig and defined **without** a `baseUrl`.
Resolving that alias in the **webpack** builder relies on the
`load-jsconfig.ts` change from #92277 (compute the effective base URL
from `pathsBasePath`), which had not been backported to `next-16-2`.
Only the source change from #92277 is included here — its test
reorganization is not.
## Test changes
The `test/production/ci-missing-typescript-deps` and
`test/production/next-server-nft` suites were converted from
`createNext` to `nextTestSetup` on `canary` in #93799, which was never
backported to `next-16-2`. Because #95639's test diffs were authored
against that refactored shape, the `ci-missing-typescript-deps` suite is
adapted back to this branch's existing `createNext` / `try‑finally`
style rather than pulling in the #93799 refactor.
## Fixes
Fixes #95801
## Verification
Automated (both bundlers):
- `pnpm --filter=next build`
- `pnpm test-start-turbo` and `pnpm test-start-webpack` for:
- `test/production/app-dir/typescript-cli/typescript-cli.test.ts`
- `test/production/ci-missing-typescript-deps/index.test.ts`
- Unit: `runTypeScriptCli.test.ts`,
`test/unit/typescript-cli-config-origin/index.test.ts`
Against a `typescript@7.0.2` reproduction project, `next build` no
longer crashes with an error about how `"id"` should be a string`. It
now exits cleanly with actionable guidance:
```
▲ Next.js 16.2.10 (Turbopack)
Creating an optimized production build ...
✓ Compiled successfully in 785ms
Running TypeScript .TypeScript 7.0.2 does not provide the compiler API required by Next.js. Enable experimental.useTypeScriptCli in your Next.js config to use the TypeScript CLI, or install TypeScript 6 instead.
Next.js build worker exited with code: 1 and signal: null
```
The same clean error is produced under `CI=1` (previously the crash
path). Enabling the new opt-in:
```ts
experimental: {
useTypeScriptCli: true,
},
```
makes the build succeed with TypeScript 7 installed.
---------
Co-authored-by:
Tim Neutkens <tim@timneutkens.nl>
Showing
This diff is collapsed.
Please
register
or
sign in
to comment