[api-extractor] Upgrade bundled TypeScript to 6.0.x#5841
Open
hl662 wants to merge 3 commits into
Open
Conversation
Bump the bundled compiler from 5.9.3 to 6.0.3. The 6.0 compiler produces byte-identical api-extractor output, so no golden snapshots changed. - pin typescript 5.9.3 -> 6.0.3 in apps/api-extractor - add 6.0.3 to common-versions allowed alternatives (keep 5.9.3, still required by the published @microsoft/api-extractor pulled in transitively) - retarget TypeScriptInternals source-pointer comments to the v6.0.3 tag - regenerate lockfiles / repo-state for the default and build-tests subspaces Internals validated against v6.0.3: getDiagnosticsProducingTypeChecker was removed but the existing getTypeChecker fallback handles it; all other shims unchanged. The TS1540 grammar diagnostic that broke microsoft#5793 does not appear in this repo's build-tests graph. While here (Boy Scout cleanup, motivated by the internals review): - remove the dead `getDiagnosticsProducingTypeChecker ?? getTypeChecker` branch in getGlobalVariableAnalyzer. That API was removed from the compiler in TypeScript 4.7 when the dual type-checker was unified, so the fallback has been dead since api-extractor bundled 4.7+; simplify to the public Program.getTypeChecker(). Behavior-preserving. - add TypeScriptInternals.test.ts, a regression test that pins the getTypeChecker -> getEmitResolver -> hasGlobalName internal chain (catches silent semantic drift on a future compiler bump, which the existence-only InternalError guards do not). Refs microsoft#5052, microsoft#5319. Supersedes microsoft#5793.
…Script 6.0 compatibility The TypeScript 6.0 compiler now bundled by API Extractor reports the TS1540 grammar error for the legacy `module` namespace keyword, which playwright-core's protocol.d.ts used through 1.56.1. Playwright converted those declarations to `namespace` in 1.58 (microsoft/playwright#38558), so without this bump, running API Extractor over @rushstack/playwright-browser-tunnel fails the production build. Upgrade playwright, playwright-core, and @playwright/test to 1.58.2 across the playwright-browser-tunnel app and the playwright-local-browser-server VS Code extension.
Author
|
@microsoft-github-policy-service agree |
…r under TS 6.0 API Extractor analyzes each project with its own bundled TypeScript compiler, which this PR advances to 6.0. TypeScript 6.0 changes the default CommonJS moduleResolution from "node10" to "bundler", and "bundler" cannot resolve the types of @modelcontextprotocol/sdk's subpath exports (which lack a "types" condition) -- producing a TS2307 flood that fails the production build. Pin moduleResolution to "node10" -- the resolution this project already compiles under via the repo toolchain -- so API Extractor's analysis matches the build. No change to the published package.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrades
@microsoft/api-extractor's bundled TypeScript compiler from5.9.3to6.0.3(the latest stable 6.0.x).api-extractor bundles a pinned compiler because it relies on undocumented compiler internals, so the bundled version has to be advanced and re-validated deliberately on each release rather than floated.
I noticed #5793 made an attempt to bump to TS 6.0.x, but it ran into CI problems. The newer compiler reports the grammar error TS1540 for the legacy
module Foo {}namespace keyword.playwright-core'sprotocol.d.tsused that keyword through1.56.1, and because api-extractor treats compiler warnings as errors in production mode, this failed the build of this repo's own@rushstack/playwright-browser-tunnel.Playwright fixed this in
1.58(microsoft/playwright#38558), so this PR also bumps the repo's pinned Playwright to1.58.2.@modelcontextprotocol/sdk@1.10.2 exposes its subpath types via exports["./*"] with no "types" condition, so under the 6.0 compiler's new default (moduleResolution: bundler) they no longer resolve. Node10 restores the resolution rushstack's
mcp-serveralready compiles under.Bumping the compiler surfaced a second, smaller compatibility issue. TS 6.0 also flips the default CommonJS
moduleResolutionfromnode10tobundler, and underbundlerapi-extractor's analysis can't resolve@modelcontextprotocol/sdk's subpath-export types (they lack atypescondition), so@rushstack/mcp-server's production build fails with a TS2307 flood. I tried bumping the SDK first, but the only release with fixedexports(1.29) drags in a zod 3→4 migration — too much for this PR — so I pinnedmoduleResolution: node10for mcp-server, which is the resolution it already compiles under.I was looking ahead towards TS 7, and knowing that api-extractor uses some compiler internals, I assume there are regression concerns, since the newer compiler likely won't be at feature parity with the current one. So I also added a test file for TypeScriptInternals, and noticed there was dead code in there.
getDiagnosticsProducingTypeCheckerwas removed from the compiler in 4.7 (the dual type-checker was unified intogetTypeChecker); the existing?? getTypeCheckerfallback already handled it, so I've consolidated the code path to just begetTypeChecker. Wrote a test case for this in a newTypeScriptInternals.test.ts, that can be expanded ahead of TS 7 to cover the other internal methods, if you think that's worthwhile.Refs #5052, #5319. Supersedes #5793.
Details
The change is split into three commits:
1. Upgrade the bundled compiler (+ a small cleanup):
typescriptto6.0.3inapps/api-extractor/package.json; added6.0.3to thetypescriptallowed-alternatives incommon-versions.json(kept5.9.3, still required by the published@microsoft/api-extractorpulled in transitively); regenerated the lockfiles /repo-state.json.(ts as any)internals shim inTypeScriptInternals.tsagainst thev6.0.3source, refreshed the source-pointer comments, and removed the deadgetDiagnosticsProducingTypeCheckerbranch (see Summary). Other shims are unchanged.TypeScriptInternals(pins thegetTypeChecker → getEmitResolver → hasGlobalNamechain).2. Bump Playwright to 1.58.2 (for TS 6.0 compatibility):
playwright,playwright-core, and@playwright/testfrom1.56.1to1.58.2inplaywright-browser-tunneland theplaywright-local-browser-serverVS Code extension, picking up fix: address TypeScript 6.0 deprecations playwright#38558 which convertsprotocol.d.tsfrom the legacymodulekeyword tonamespace. Without it, api-extractor's analysis of the tunnel emits the TS1540 flood and fails the production build under the new compiler.3. Pin
moduleResolution: node10for@rushstack/mcp-server(for TS 6.0 compatibility):moduleResolutiontobundler, under which api-extractor's analysis can't resolve@modelcontextprotocol/sdk@1.10.2's subpath-export types (notypescondition) → TS2307. Pinningnode10in mcp-server'stsconfig.json— the resolution it already compiles under via the repo toolchain — realigns the analysis with the build. No change to the published package.How it was tested
All results below are from local runs on my Mac, running Node 24.14.0; CI will re-verify.
rush rebuild --to @microsoft/api-extractorbuilds clean against the 6.0 typings;rush test --to @microsoft/api-extractorpasses (80 tests, incl. the newTypeScriptInternalstest).rush rebuild --to @rushstack/playwright-browser-tunnel --production(the mode CI uses) failed on the TypeScript bump alone with 126 TS1540 diagnostics fromplaywright-core@1.56.1/protocol.d.ts; after bumping Playwright to 1.58.2 it builds clean (0 TS1540). Theplaywright-local-browser-serverextension also builds clean under--production.rush rebuild --to @rushstack/mcp-server --productionfailed with TS2307 on@modelcontextprotocol/sdkunder the bump; with thenode10pin it builds clean (0 TS2307, no deprecation warning, no golden change).etc/snapshots are unchanged.rush rebuild --production(matching CI's mode): the only failure islocalization-plugin-test-03 (build), which is unrelated to this change — untouched by this PR, builds with the repo toolchain TypeScript, and present onmain(it reproduces only on my machine;main's CI is green).Impacted documentation
None.