[code-infra] Run TypeScript 7 alongside the TS6 JS API - #1828
[code-infra] Run TypeScript 7 alongside the TS6 JS API#1828brijeshb42 wants to merge 16 commits into
Conversation
TypeScript 7 ships only the native tsc binary; the JS API that typescript-eslint, docs-infra type extraction, and Next.js consume now lives in @typescript/typescript6. typescript-eslint hard-errors on TS 7 and support is at least a major away (typescript-eslint#10940), so the Renovate typescript major (#1663) cannot land as-is. Follow the side-by-side setup documented in the TS 7.0 announcement: - alias typescript to @typescript/typescript6 so every JS API consumer keeps resolving a 6.x API under the name it imports - install TS 7 as "@typescript/native": "npm:typescript@^7.0.2" and point package typescript/build scripts at its tsc - teach code-infra's findTsgo to probe @typescript/native/bin/tsc before the discontinued @typescript/native-preview tsgo, and declare the new optional peer, so downstream repos can migrate the same way Per-package typescript6 dev deps are required: pnpm installs a workspace importer's peers locally, and a real typescript@6 install would shadow the workspace-root TS 7 tsc with its own .bin/tsc. The alias's bin is named tsc6, which removes the shadowing.
Deploy previewBundle sizeTotal Size Change: 0B(0.00%) - Total Gzip Change: 0B(0.00%) Show details for 71 more bundles@mui/internal-docs-infra/abstractCreateDemo parsed: 0B(0.00%) gzip: 0B(0.00%) PerformanceTotal duration: 19.23 ms +2.56 ms(+15.3%) | Renders: 5 (+0) | Paint: 68.44 ms +8.26 ms(+13.7%)
4 tests within noise — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
Next.js 16.3 enables experimental.useTypeScriptCli by default and requires the typescript package to ship a bin/tsc. The TypeScript 7 side-by-side setup aliases typescript to @typescript/typescript6, whose bin is tsc6, so next build aborts reporting typescript as missing. Default useTypeScriptCli to false on Next.js >= 16.3; docs-infra requires the TS6 JS API for type extraction anyway. Consumers can still opt back in through their own experimental config.
The nightly @typescript/native-preview package is discontinued in favor of stable TypeScript 7. Remove its optional peer dependency and the .bin/tsgo fallback probe; the native compiler is now found only through the documented "@typescript/native": "npm:typescript@^7.0.0" alias.
Spawning @typescript/native/bin/tsc directly fails on Windows: the shebang script is not executable by cmd. Probe the pnpm .bin shims instead, matching how the old .bin/tsgo probe worked cross-platform. In the side-by-side setup the native compiler owns the workspace-root tsc bin and the TS6 JS CLI is exposed as tsc6, so the native check now looks for .bin/tsc and the JS path prefers .bin/tsc6 (package first, then workspace root) before falling back to plain tsc from PATH for repos not on the alias.
Resolve the native/JS CLI pair in one place: a workspace-root tsgo shim (legacy @typescript/native-preview install, where typescript still owns tsc) selects the tsgo/tsc pair; otherwise the TypeScript 7 side-by-side pair tsc/tsc6 applies. Consumer repos still on the nightly keep building with the new code-infra until they migrate.
The typescript6 alias and @typescript/native now live only in the root package.json; per-package copies are gone. This requires autoInstallPeers: false — pnpm otherwise fetches a real typescript for per-package peers (typescript-eslint requires one), whose .bin/tsc shadows the root native tsc, and 404s on @typescript/native, an alias rather than a registry package. Unmet typescript peers now resolve through the root at runtime. Turning off peer auto-install exposed deps test-utils imported but never declared (@emotion/*, chai, react, react-dom); declare them as devDependencies.
This reverts commit b15f2f2.
e038e3d to
7a573a5
Compare
The dashboard's minimal next.config gets no help from withDeploymentConfig, so the Next.js >= 16.3 default CLI checker looks for a tsc bin the typescript6 alias does not ship and aborts the build reporting typescript as missing. Opt into the TS6 JS API like the docs site. No local typescript install is needed; the root alias resolves by walking up.
This reverts commit ac7026d.
This reverts commit b3e74d8.
Next.js 16.3's default CLI checker supports TypeScript 7, so instead of opting the apps into the TS6 JS API, install real typescript@7 in docs and code-infra-dashboard. Next.js finds its tsc bin locally and type-checks natively. docs-infra still consumes the TS6 JS API through its own devDependency via the workspace link.
|
@claude review |
|
Review depth: medium (one main-agent pass over Bugs / Tests / Simplifications / Docs, verified locally against PR reviewThe dependency rewiring looks coherent — the Bugs (2)1. 🟠
|
Review follow-up: the tsc6 probe walked the package directory first while the native probe checked only the workspace root. Both halves of the pair now resolve from the workspace root's node_modules/.bin, probed in parallel.
- Drop the MUI_USE_TSGO env var; --tsgo stays as the only switch. - Log the resolved compiler path on both emit paths, labelled ts-native on the native one, so builds show which tsc actually ran. - Drop the @typescript/native optional peer: nothing checks that name and consumers installing plain typescript@7 could never satisfy it. The error message now states the real requirement. - Reword the stale tsgo help text.
Type extraction requires the TypeScript 6 JS API, but the required `typescript` peer resolved it from the consuming docs app — a docs app on typescript@7 (for the Next.js CLI type checker) then feeds docs-infra an API-less compiler and the build dies with "ts.readConfigFile is not a function". Ship the typescript6 alias as a regular dependency instead, the same pattern typescript-api-extractor already uses, and drop the peer. Consumer apps are then free to run any typescript version.
Adopts the side-by-side setup from the TS 7.0 announcement: TS 7 ships only the native
tsc, the JS API moved to@typescript/typescript6, and typescript-eslint hard-errors on TS 7 (typescript-eslint#10940) — which is why #1663 fails across the board.Changes
typescript→npm:@typescript/typescript6@^6.0.2alias wherever the JS API is resolved (typescript-eslint, docs-infra type extraction). The alias bin istsc6, so it doesn't shadow the root TS 7tsc."@typescript/native": "npm:typescript@^7.0.2"; packagetypescript/buildscripts run itstsc.typescript@7and type-check through Next 16.3's TypeScript CLI..binshims:tsgo/tscon the legacy@typescript/native-previewnightly,tsc/tsc6on this setup. All native-preview usage in this repo is removed.Verification
pnpm typescript,eslint,release:build,test --run,prettier, docs and dashboard builds — all pass.masterwith this PR's code-infra (via pkg.pr.new):pnpm build,release:build,typescript, jsdom unit suite (7874 tests),extract-error-codes— all pass through the legacytsgopath. The eslint delta there (5.5k auto-fixablevitest/*errors) comes from [code-infra] Make vitest the default in createTestConfig, import globals instead #1798, not this PR.Follow-ups