Port microsoft/TypeScript PR #62391: Switch libReplacement to false by default #1852
+376,362
−49,447
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.
This PR ports microsoft/TypeScript#62391, which changes the
libReplacement
compiler option default fromtrue
tofalse
, making library replacement an opt-in feature.Background
The
libReplacement
option controls whether TypeScript attempts to resolve library files (likelib.es2015.d.ts
) from@typescript/lib-*
npm packages instead of using the built-in library files. PR #62391 in TypeScript changed this behavior from opt-out to opt-in.Changes Made
The Go codebase already had the correct implementation of this feature:
internal/tsoptions/declscompiler.go
: Already hasDefaultValueDescription: false
internal/compiler/fileloader.go
: Already usesLibReplacement.IsTrue()
which only enables lib replacement when explicitly set totrue
Therefore, the main changes in this PR are:
1ee9e0d9a
to1112daead
to include PR #62391 and bring in the latest changesinternal/tsoptions/tsconfigparsing_test.go
to include new transformer files (es2015.ts
andgenerators.ts
) that were added to the TypeScript sourceBehavior
With this change, the behavior is now:
libReplacement
isundefined
(not specified): Uses default TypeScript libs ✓libReplacement
is explicitlyfalse
: Uses default TypeScript libs ✓libReplacement
is explicitlytrue
: Attempts to resolve replacement libs from@typescript/lib-*
packagesThis aligns the Go implementation with the updated TypeScript behavior where library replacement is opt-in rather than default.
Testing
Original prompt
Note
Custom agent used: Strada to Corsa Port Expert
A Go and TypeScript expert who can easily figure out how to port PRs from one language to another
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.