Skip to content

fix(55825): rebase inherited paths in --showConfig - #65820

Open
Sumit G (smg99) wants to merge 1 commit into
microsoft:mainfrom
smg99:fix/55825-showconfig-paths
Open

Sumit G (smg99) wants to merge 1 commit into
microsoft:mainfrom
smg99:fix/55825-showconfig-paths

Conversation

@smg99

Copy link
Copy Markdown
Contributor

Fixes #55825

Problem

--showConfig printed inherited paths mappings verbatim. Runtime resolution already uses PathsBasePath (the directory of the config that defined paths), so an extended config's "./bar" still resolved under that extended directory, but showConfig under the child kept printing "./bar".

Fix

When serializing paths for showConfig, rebase mappings relative to the consuming config whenever PathsBasePath differs from that config's directory:

  • Resolve the relative difference from PathsBasePath to the consuming config directory
  • Normalize only the path prefix before the first *
  • Preserve trailing directory separators and leave the * suffix (and anything after it) unchanged
  • Leave absolute entries and same-directory / empty-PathsBasePath cases unchanged (including case-only directory differences on case-insensitive hosts)

Wired through serializeCompilerOptionPaths in showconfig.go, the generate-options.ts serializer special-case for paths, and the reflected serializer used by TestShowConfigSerialization.

Before / after (tsc --showConfig)

Given a root config that extends ./this-path-should-be-in-config/tsconfig.json with paths.foo: ["./bar"]:

Before

"paths": {
    "foo": [
        "./bar"
    ]
}

After

"paths": {
    "foo": [
        "./this-path-should-be-in-config/bar"
    ]
}

Parent-extends case (extends: "../tsconfig.base.json" with "@/*": ["./src/*"]) now prints "../src/*".

Tests

  • Show TSConfig with inherited paths from extended config (--showConfig doesn't resolve paths #55825 repro, including a wildcard mapping)
  • Show TSConfig with inherited paths from parent extended config
  • TestSerializeCompilerOptionPaths direct assertions for trailing slash, */../x, bare *, absolute entries, same-dir identity, and case-only base-path differences

Checklist

  • There is an associated issue in the Backlog milestone (required)
  • Code is up-to-date with the main branch
  • You've successfully run npx hereby test (via npx hereby validate; also focused go test ./tsc/internal/tsoptions/ ./tsc/internal/execute/tsctests/)
  • You've successfully run npx hereby lint (via npx hereby validate; 0 issues)
  • You've successfully run npx hereby check:format (via npx hereby validate + npx hereby tidy)
  • There are new or updated tests validating the change

Serialize paths relative to the consuming config when PathsBasePath
differs, so extended mappings match runtime resolution.
Copilot AI balanced review requested due to automatic review settings December 5, 2026 07:25
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Dec 5, 2026
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Dec 5, 2026

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.

🟡 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

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.

--showConfig doesn't resolve paths

2 participants