Skip to content

Validate wildcard package export targets in the native resolver - #65504

Open
祈雨 (qiyuhuating) wants to merge 3 commits into
microsoft:mainfrom
qiyuhuating:fix/native-export-wildcard-containment
Open

祈雨 (qiyuhuating) wants to merge 3 commits into
microsoft:mainfrom
qiyuhuating:fix/native-export-wildcard-containment

Conversation

@qiyuhuating

@qiyuhuating 祈雨 (qiyuhuating) commented Nov 14, 2026 •

Copy link
Copy Markdown

Fixes #63499. Follow-up to the closed TypeScript 6 PR #63543, now targeting the native Go resolver.

Problem

Wildcard package.json export 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 ., .., and node_modules segment check before either wildcard expansion or literal target resolution. Add regression cases for invalid patterns and a valid wildcard.

Verification

  • Unpatched baseline: TestWildcardExportTargetContainment/nested_node_modules fails (2 entrypoints; expected 1).
  • Patched: targeted and full module tests pass.
  • Windows / Go 1.27.3 / Node.js 24.16.0:
    • npx hereby validate --all --no-generate passed (compiler, extension, native/WASM API, tools, smoke, lint and format).
    • npx hereby generate and npx hereby test:codegen passed with NODE_OPTIONS=--use-system-ca.
    • npx hereby check:format, npx hereby tidy, and git diff --exit-code passed.

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.

Copilot AI balanced review requested due to automatic review settings November 14, 2026 11:16
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 14, 2026
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 14, 2026
@typescript-automation

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 ., .., and node_modules segment 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

@typescript-automation typescript-automation Bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Wildcard package.json exports auto-import path does not apply traversal containment checks

2 participants