Handle optional compat patch failures for TypeScript 7#7190
Handle optional compat patch failures for TypeScript 7#7190hamidrezahanafi wants to merge 2 commits into
Conversation
|
Thanks for this. Bounding the patch to The TypeScript 7.0 RC announcement recommends a side-by-side install that aliases {
"devDependencies": {
"typescript": "npm:@typescript/typescript6@^6.0.0",
"typescript-7": "npm:typescript@rc"
}
}
Repro on # .yarnrc.yml
nodeLinker: node-modules{ "devDependencies": { "typescript": "npm:@typescript/typescript6@^6.0.0" } }
Two more robust options, either of which also covers the alias case:
(1) is the precise fix; (2) is good defense-in-depth and matches what the docs say Happy to help if you want it! |
|
I think the optional qualifier being ignored is a proper bug to fix, yeah - also something curious in the current PR, it seems to be breaking a test 🤔 |
|
Thanks @maik-bol and @arcanis , that makes sense. I updated the PR to address this in two layers:
I also added coverage for the alias case from the TS 7 recommendation: {
"typescript": "npm:@typescript/typescript6@^6.0.0"
}So this should cover both direct On the CI failure: |
Co-authored-by: Cursor <cursoragent@cursor.com>
1c09061 to
ce3dafd
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
Amazing work, thanks for the effort! |
Summary
optional!patches fall back when a package no longer ships a target file (for examplelib/_tsc.jsin TypeScript 7 / TypeScript compatibility shims), instead of failing the install withENOENT.typescript@7.0.1-rcinstalls and the TypeScript 7 side-by-side recommendation where thetypescriptident aliases tonpm:@typescript/typescript6@^6.0.0.plugin-typescriptacceptance test by moving it from@babel/traverse(now reported by npm search metadata as having included types) to a fixture package that still exercises DefinitelyTyped scoped package insertion.Test plan
yarn workspace @yarnpkg/plugin-compat test:plugin-compatyarn test:unit packages/plugin-patchnode ./scripts/run-yarn.js test:integration packages/acceptance-tests/pkg-tests-specs/sources/plugins/plugin-typescript.test.tsyarn version checkNotes
TypeScript 7 ships a native compiler package layout and no longer has the legacy JS compiler files patched by the existing PnP compatibility diff, such as
lib/_tsc.js. Bounding the TypeScript compat patch makes this intent explicit, while the optional patch fallback fixes the broader bug thatoptional!patch failures caused by missing target files were still fatal.TypeScript 7 support should ship with microsoft/typescript-go#1966.
Made with Cursor