Repository navigation
Validate wildcard package export targets in the native resolver - #65504
Open
祈雨 (qiyuhuating) wants to merge 3 commits into
Open
祈雨 (qiyuhuating) wants to merge 3 commits into
祈雨 (qiyuhuating) wants to merge 3 commits into
Conversation
Contributor
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the wildcard package-export validation change.
No open issues 🎉
What changed in this PR
This PR aligns wildcard package-export validation with literal-target validation in the native Go resolver, preventing invalid targets from contributing auto-import entrypoints.
Changes:
- Applies the existing
.,.., andnode_modulessegment checks before wildcard expansion or literal resolution. - Adds regression cases for invalid wildcard targets and a valid pattern, while checking that the package-root entrypoint remains available.
| File | Description |
|---|---|
tsc/internal/module/resolver.go |
Moves target validation ahead of both resolution branches. |
tsc/internal/module/resolver_test.go |
Adds table-driven coverage for invalid and valid wildcard targets. |
Review effort: Balanced
This branch has not been deployed
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.
Fixes #63499. Follow-up to the closed TypeScript 6 PR #63543, now targeting the native Go resolver.
Problem
Wildcard
package.jsonexport targets bypass the path-segment validation already used for literal targets. For example,"./node_modules/*.d.ts"contributes an invalid auto-import entrypoint.Fix
Apply the existing
.,.., andnode_modulessegment check before either wildcard expansion or literal target resolution. Add regression cases for invalid patterns and a valid wildcard.Verification
TestWildcardExportTargetContainment/nested_node_modulesfails (2 entrypoints; expected 1).npx hereby validate --all --no-generatepassed (compiler, extension, native/WASM API, tools, smoke, lint and format).npx hereby generateandnpx hereby test:codegenpassed withNODE_OPTIONS=--use-system-ca.npx hereby check:format,npx hereby tidy, andgit diff --exit-codepassed.This is a correctness fix, not a claimed security vulnerability.
AI assistance disclosure: The patch and tests were prepared with ChatGPT assistance for this specific issue; local verification was run on the contributor's machine.