-
Notifications
You must be signed in to change notification settings - Fork 1k
Complete the TypeScript 7 compatibility bridge #19130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Adam Ratzman (adamint)
wants to merge
44
commits into
microsoft:main
from
adamint:adamint/issue18905-ts7-bridge
Closed
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
54d4859
Move the TypeScript surfaces onto the TypeScript 7 bridge
8e49f2d
Close the gaps the TypeScript 7 bridge left behind
9109d38
Parse lockfile URLs instead of substring-matching, and guard bun/pnpm…
8b305ae
Route lockfile changes to the guard that checks them
86c166a
Point every package manager at the approved feed before installing
59da954
Ship the registry helper in the validation image
5ace3e7
Record the shipped lockfiles the guard does not yet cover
2b89750
Pin the origins the unnormalized lockfiles are allowed to use
a4c07f3
Stop ambient scoped registries from redirecting fixture installs
e23c221
Stop aspire init producing an uninstallable manifest on TypeScript 7
9eb7c5e
Ask yarn its version in the directory the registry check reads
fff3a50
Reject unapproved npm registry overrides
6d9969d
Pin Azure Functions Core Tools install in tests
f48bb4e
Revert "Pin Azure Functions Core Tools install in tests"
2c5b6ca
Make registry source-order guard check source command
cab6897
Pin TypeScript bridge dependency versions
31f6107
Treat unknown TypeScript specs as lint-incompatible
03a924b
Synchronize TypeScript SDK test lockfile
ebed819
Keep TypeScript lint scaffolding installable
899defd
Fix TypeScript bridge review gaps
adamint d6c4757
Route polyglot lockfiles by shape so the unknown-format guard can run
adamint 5748bf8
Route the polyglot fixture tree instead of lockfile shape
adamint 0253642
Own the npm config in Dockerfile.typescript and route every shipped l…
5984803
Reject Yarn scoped registries that are not the approved feed
497d4c2
Fix the orphaned Dockerfile block and catch the shape in a test
72fc837
Prove the npm scope re-pin won and stop the yarn scope check failing …
8aa1219
Close the bun and corepack registry holes in the polyglot preflight
b552aa3
Reject fixture dependency specs that bypass the registry
ff92d95
Pin the TypeScript scaffold to versions the approved feed can serve
3d5d26c
Leave a project-owned typescript-eslint spec alone and scan configs b…
Copilot eab854d
Close the dependency-spec bypasses the fixture guard still had
9bcc3dd
Read bun's ambient config by URL instead of by line shape
24e3a88
Move the linter with the compiler, and ship the lockfiles to Helix
Copilot b46e312
Decide TypeScript support by the range's upper bound and move npm ove…
Copilot 0b1607b
Move a self-scoped override entry too
Copilot b59b291
Compute npm range bounds from the components a literal spells out
adamint bb84866
Reconcile a project's linter spec when the merge upgrades TypeScript
adamint 6c68397
Reconcile an npm override against every direct spec the merge writes
e6258de
Merge branch 'main' into adamint/issue18905-ts7-bridge
adamint f9583b5
Keep the TypeScript 7 bridge focused
0d02f95
Preserve compatible brownfield npm ranges
dd4785a
Merge branch main into adamint/issue18905-ts7-bridge
26e7932
Keep starter lockfiles customer-reachable
3807f2d
Include the Rust fixture in the TypeScript bridge
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| 'use strict'; | ||
|
|
||
| // Type-checks the extension with the TypeScript 7 native (Go) compiler. | ||
| // | ||
| // TypeScript 7 ships no JavaScript compiler API, so `typescript` stays aliased to the | ||
| // `@typescript/typescript6` compatibility package for everything that imports the module, and the | ||
| // native compiler is installed under the `@typescript/native` alias. See "Running Side-by-Side with | ||
| // TypeScript 6.0" in https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/. | ||
| // | ||
| // The compiler is resolved through Node's module resolution and the package's own `bin` field | ||
| // rather than a path such as `node_modules/@typescript/native/bin/tsc`. Two things make the literal | ||
| // path wrong to depend on: which directory a package manager installs an aliased package into is | ||
| // not contractual (npm, Yarn, pnpm and Bun all differ, and pnpm's default layout is not flat), and | ||
| // the `bin` entry is the package's own declaration of where its executable lives. Resolving | ||
| // `node_modules/.bin/tsc` instead is also wrong, because `@typescript/old` — pulled in transitively | ||
| // by the TypeScript 6 compatibility package — declares a `tsc` bin too, and which one wins the | ||
| // shim is decided by install order. | ||
|
|
||
| const { spawnSync } = require('child_process'); | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| const nativePackageName = '@typescript/native'; | ||
| const extensionRoot = path.resolve(__dirname, '..'); | ||
|
|
||
| // Every project the extension compiles needs to pass the native compiler, not only the one webpack | ||
| // and the unit tests build. tsconfig.e2e.json covers src/test-e2e, which is compiled separately by | ||
| // `compile-e2e` and is otherwise excluded from tsconfig.json. | ||
| const projects = ['tsconfig.json', 'tsconfig.e2e.json']; | ||
|
|
||
| function resolveNativeCompiler() { | ||
| let packageJsonPath; | ||
| try { | ||
| packageJsonPath = require.resolve(`${nativePackageName}/package.json`, { paths: [extensionRoot] }); | ||
| } | ||
| catch { | ||
| throw new Error(`Could not resolve "${nativePackageName}". Run "corepack yarn install" in ${extensionRoot} first.`); | ||
| } | ||
|
|
||
| const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); | ||
|
|
||
| // The `bin` field is either a string (single executable named after the package) or a map of | ||
| // executable name to path. typescript@7 publishes { "tsc": "./bin/tsc" }. | ||
| const bin = packageJson.bin; | ||
| const relativeBinPath = typeof bin === 'string' ? bin : bin?.tsc; | ||
| if (!relativeBinPath) { | ||
| throw new Error(`"${nativePackageName}" (${packageJson.name}@${packageJson.version}) declares no "tsc" bin: ${JSON.stringify(bin)}`); | ||
| } | ||
|
|
||
| const binPath = path.resolve(path.dirname(packageJsonPath), relativeBinPath); | ||
| if (!fs.existsSync(binPath)) { | ||
| throw new Error(`"${nativePackageName}" declares its tsc bin at ${relativeBinPath}, but ${binPath} does not exist.`); | ||
| } | ||
|
|
||
| return { binPath, version: packageJson.version }; | ||
| } | ||
|
|
||
| function main() { | ||
| const { binPath, version } = resolveNativeCompiler(); | ||
| console.log(`Type-checking with the TypeScript ${version} native compiler (${path.relative(extensionRoot, binPath)}).`); | ||
|
|
||
| for (const project of projects) { | ||
| const projectPath = path.join(extensionRoot, project); | ||
| if (!fs.existsSync(projectPath)) { | ||
| throw new Error(`Expected to type-check ${project}, but it does not exist in ${extensionRoot}.`); | ||
| } | ||
|
|
||
| console.log(` → ${project}`); | ||
|
|
||
| // The bin is a Node script without a portable shebang on Windows, so it is run through the | ||
| // current Node executable rather than executed directly. | ||
| const result = spawnSync(process.execPath, [binPath, '--noEmit', '-p', projectPath], { | ||
| cwd: extensionRoot, | ||
| stdio: 'inherit', | ||
| }); | ||
|
|
||
| if (result.error) { | ||
| throw result.error; | ||
| } | ||
|
|
||
| if (result.status !== 0) { | ||
| process.exit(result.status ?? 1); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| try { | ||
| main(); | ||
| } | ||
| catch (error) { | ||
| console.error(error instanceof Error ? error.message : error); | ||
| process.exit(1); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.