Repository navigation
fix(55825): rebase inherited paths in --showConfig - #65820
Open
Sumit G (smg99) wants to merge 1 commit into
Open
Sumit G (smg99) wants to merge 1 commit into
Sumit G (smg99) wants to merge 1 commit into
Conversation
Serialize paths relative to the consuming config when PathsBasePath differs, so extended mappings match runtime resolution.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Path normalization mishandles wildcard components and empty relative prefixes, producing incorrect or absolute mappings that redirect module resolution.
2 open issues
1 file not reviewed
tsc/internal/tsoptions/options_generated.go: Generated file
What changed in this PR
Addresses #55825 by rebasing inherited paths mappings in TypeScript’s --showConfig output relative to the consuming config.
Changes:
- Adds path-mapping serialization with wildcard and separator handling.
- Updates generated and reflected serializers.
- Adds focused tests and CLI baselines for inherited mappings.
| File | Description |
|---|---|
| tsc/testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-inherited-paths-from-parent-extended-config.js | Records parent-config output. |
| tsc/testdata/baselines/reference/tsc/showConfig/Show-TSConfig-with-inherited-paths-from-extended-config.js | Records subdirectory-config output. |
| tsc/internal/tsoptions/showconfig.go | Implements mapping rebasing. |
| tsc/internal/tsoptions/showconfig_test.go | Adds serializer edge-case tests. |
| tsc/internal/tsoptions/options_generated.go | Routes mappings through the serializer. |
| tsc/internal/execute/tsctests/showconfig_test.go | Adds inherited-config CLI scenarios. |
| tools/scripts/tsc/generate-options.ts | Generates the serializer integration. |
Review effort: Balanced
| star := strings.IndexByte(value, '*') | ||
| prefix, suffix := value, "" | ||
| if star >= 0 { | ||
| prefix, suffix = value[:star], value[star:] |
| prefix, suffix = value[:star], value[star:] | ||
| } | ||
| hadTrailingSep := prefix != "" && tspath.HasTrailingDirectorySeparator(prefix) | ||
| normalized := tspath.NormalizePath(tspath.CombinePaths(relativeBase, prefix)) |
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 #55825
Problem
--showConfigprinted inheritedpathsmappings verbatim. Runtime resolution already usesPathsBasePath(the directory of the config that definedpaths), so an extended config's"./bar"still resolved under that extended directory, but showConfig under the child kept printing"./bar".Fix
When serializing
pathsfor showConfig, rebase mappings relative to the consuming config wheneverPathsBasePathdiffers from that config's directory:PathsBasePathto the consuming config directory**suffix (and anything after it) unchangedPathsBasePathcases unchanged (including case-only directory differences on case-insensitive hosts)Wired through
serializeCompilerOptionPathsinshowconfig.go, thegenerate-options.tsserializer special-case forpaths, and the reflected serializer used byTestShowConfigSerialization.Before / after (
tsc --showConfig)Given a root config that extends
./this-path-should-be-in-config/tsconfig.jsonwithpaths.foo: ["./bar"]:Before
After
Parent-extends case (
extends: "../tsconfig.base.json"with"@/*": ["./src/*"]) now prints"../src/*".Tests
Show TSConfig with inherited paths from extended config(--showConfigdoesn't resolvepaths#55825 repro, including a wildcard mapping)Show TSConfig with inherited paths from parent extended configTestSerializeCompilerOptionPathsdirect assertions for trailing slash,*/../x, bare*, absolute entries, same-dir identity, and case-only base-path differencesChecklist
Backlogmilestone (required)mainbranchnpx hereby test(vianpx hereby validate; also focusedgo test ./tsc/internal/tsoptions/ ./tsc/internal/execute/tsctests/)npx hereby lint(vianpx hereby validate; 0 issues)npx hereby check:format(vianpx hereby validate+npx hereby tidy)