fix: resolve tsconfig extends via package.json exports field#308156
Open
maruthang wants to merge 1 commit into
Open
fix: resolve tsconfig extends via package.json exports field#308156maruthang wants to merge 1 commit into
maruthang wants to merge 1 commit into
Conversation
The document link provider for tsconfig "extends" values now consults the package.json "exports" field when resolving module subpaths. This fixes the case where a package remaps subpath exports (e.g., "./*/tsconfig.json" -> "./lib/*/tsconfig.json") and VS Code fails to navigate to the resolved file while tsc resolves it correctly. Supports exact matches, single-wildcard patterns, and conditional exports (types > import > require > default). Falls back to direct path resolution when no exports field or match is found. Fixes microsoft#276592
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 #276592
Summary
cmd+clickon"extends"values) now resolves module subpaths throughpackage.json"exports"field mappingsresolveNodeModulesPath()performed naive directory concatenation (e.g.,node_modules/@scope/example/base/tsconfig.json) without consulting exports, causing resolution to fail when packages use subpath export remappingresolveViaPackageExports()that reads the module'spackage.json, matches the subpath against export patterns, and resolves the mapped path"./config") and wildcard patterns (e.g.,"./*/tsconfig.json" → "./lib/*/tsconfig.json")types > import > require > defaultTest plan
cmd+clickon the"extends"value navigates to the correct filetypes/import/defaultkeys) resolve correctly"./*/tsconfig.json"map correctly