(TypeScript 7 Support) Add experimental TypeScript CLI backend - #95639
Conversation
24a7cff to
65fd2b7
Compare
Stats from current PR🔴 3 regressions
📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📝 Changed Files (3 files)Files with changes:
View diffsserver.runtime.prod.jsDiff too large to display pages-api-tu..time.prod.jsDiff too large to display pages-turbo...time.prod.jsDiff too large to display 📎 Tarball URLCommit: 080d187 |
Tests PassedCommit: 080d187 |
65fd2b7 to
b7405dc
Compare
b7405dc to
8a69222
Compare
andrewimm
left a comment
There was a problem hiding this comment.
Reviewed the actual lib/typescript bits. I ran it through some scenarios that weren't explicitly tested, especially on the config handling, it seems like all of the edge cases work. Signal handling looks thorough, and I'm pretty sure the child process handling will work on Windows too (no signals, but the console should kill it with events).
| for (const signal of terminationSignals) { | ||
| const handler = createSignalHandler(signal) | ||
| signalHandlers.set(signal, handler) | ||
| process.once(signal, handler) | ||
| } |
There was a problem hiding this comment.
so this is why we run in a child worker process, when the parent calls end it will send sigterm and we will propagate
wouldn't it be better to just invoke typecript CLI directly instead of going through the jest worker? i guess the problem is doing the config resolution in the parent nodejs process? but this does simplify the invocation and avoid an extra node process spawn
typescript@7.0.2 breaks all four Next.js apps in Vercel CI. Next 16.2.10's verify-typescript-setup.js probes for typescript/lib/typescript.js to confirm TypeScript is installed — that file (and any deep import path) no longer exists in TS7's package, which ships only an exports-restricted shim to the native Go binary. Next then tries to auto-repair by running pnpm add -D typescript mid-build, which fails hard in Vercel's CI environment (confirmed via build logs: cv, financial, figmentation, x-com-chat all failed on commit dff8098 with this exact cause). Verified not a monorepo/hoisting issue: require.resolve('typescript/package.json') resolves fine from every app via pnpm's normal root-hoisting; only the deep lib/typescript.js subpath fails, due to TS7's package.json exports map (TS6 had no exports field at all, so the old deep import always worked). Next.js merged an experimental fix today (vercel/next.js#95639, experimental.useTypeScriptCli) but it isn't in a published canary yet (latest is 16.3.0-canary.82, cut before the merge). Revisit once that ships and stabilizes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
## 変更内容 ### TypeScript パッケージ構成の変更 TypeScript 7.0 は Compiler API を同梱しないため、Next.js 等の ツールとの互換性を保ちつつ TS 7 ネイティブバイナリを導入する 公式推奨の並存設定を採用。 - \ ypescript\: \ pm:@typescript/typescript6@^6.0.0\ に変更 (Next.js 等 Compiler API を使用するツール用) - \@typescript/native\: \ pm:typescript@^7.0.2\ を追加 (ネイティブ Go 実装の tsc バイナリ、8〜12x 高速) ### tsconfig の修正 (TS 7.0 破壊的変更への対応) - \packages/tsconfig/base.json\: moduleResolution \ ode\ → \�undler\ (\ ode\/\ ode10\ は TS 7.0 で廃止) - \packages/tsconfig/nextjs.json\: \ignoreDeprecations: 6.0\ を削除 (base.json の deprecation を解消したため不要) - \�pps/*/tsconfig.json\: \�aseUrl\ を削除 (TS 7.0 で廃止) paths はプロジェクトルート相対で引き続き機能する ### pnpm 設定の追加 - \minimumReleaseAge: 0\ をプロジェクトレベルで設定 (グローバルの 7 日制限をリリース直後の TS パッケージに対して解除) ## 補足 Next.js 16 stable は現時点で TypeScript 7 ネイティブ統合未対応 (canary の実験的フラグのみ: vercel/next.js#95639)。 \ equire('typescript')\ は \@typescript/typescript6\ 経由で TypeScript 6.0 API を提供し、型チェックは TS 6 で動作する。 sync-board-server 等 tsc を直接使用する場合は TS 7 ネイティブバイナリを使用。 Closes #1661 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Run next build typechecks via the project-local tsc CLI (vercel/next.js#95639) and install typescript@7 as the single compiler package, dropping the TS 6 side-by-side shim. Assisted-by: Grok Build
## Summary
- add `experimental.useTypeScriptCli` so projects can explicitly run
their local `tsc` during `next build`, including TypeScript 7 while the
legacy JavaScript API is unavailable
- preserve the TypeScript API backend as the default, with TypeScript
6-compatible dependency installation and actionable TypeScript 7
migration guidance
- load effective compiler metadata through `tsc --showConfig`, preserve
inherited path origins, stream native diagnostics, redirect incremental
state, and forward worker termination to the compiler process tree
- document the experimental behavior and cover TypeScript 6/7, both
bundlers, raw diagnostics, full-project checking, dependency selection,
and cleanup
## Demo
```
pnpm build
> cna@0.1.0 build /Users/timneutkens/projects/sandbox/cna
> next build
▲ Next.js 16.3.0-canary.81 (Turbopack)
✓ Running next.config.ts took 23ms
- Cache Components enabled
- Experiments (use with caution):
✓ useTypeScriptCli
Creating an optimized production build ...
✓ Compiled successfully in 3.9s
Running TypeScript ...
app/page.tsx:8:3 - error TS2322: Type 'string' is not assignable to type 'number'.
8 return count++ + "abc";
~~~~~~
Found 1 error in app/page.tsx:8
Failed to type check.
Next.js build worker exited with code: 1 and signal: null
ELIFECYCLE Command failed with exit code 1.
```
## Verification
- `pnpm test-start-turbo
test/production/app-dir/typescript-cli/typescript-cli.test.ts`
- `pnpm test-start-webpack
test/production/app-dir/typescript-cli/typescript-cli.test.ts`
- `pnpm test-start-turbo
test/production/ci-missing-typescript-deps/index.test.ts`
- `pnpm test-dev-turbo
test/development/typescript-native-preview/index.test.ts`
- `pnpm test-start-turbo test/production/typescript-basic/index.test.ts`
<!-- NEXT_JS_LLM_PR -->
(cherry picked from commit a249dcb)
|
What version will this release in? |
Summary
experimental.useTypeScriptCliso projects can explicitly run their localtscduringnext build, including TypeScript 7 while the legacy JavaScript API is unavailabletsc --showConfig, preserve inherited path origins, stream native diagnostics, redirect incremental state, and forward worker termination to the compiler process treeDemo
Verification
pnpm test-start-turbo test/production/app-dir/typescript-cli/typescript-cli.test.tspnpm test-start-webpack test/production/app-dir/typescript-cli/typescript-cli.test.tspnpm test-start-turbo test/production/ci-missing-typescript-deps/index.test.tspnpm test-dev-turbo test/development/typescript-native-preview/index.test.tspnpm test-start-turbo test/production/typescript-basic/index.test.ts