Skip to content

fix(tsoptions): don't mutate ParsedCommandLine errors when computing CommonSourceDirectory - #64193

Open
erantianantha wants to merge 1 commit into
microsoft:mainfrom
erantianantha:fix/parsedcommandline-commonsourcedirectory-diagnostics
Open

fix(tsoptions): don't mutate ParsedCommandLine errors when computing CommonSourceDirectory#64193
erantianantha wants to merge 1 commit into
microsoft:mainfrom
erantianantha:fix/parsedcommandline-commonsourcedirectory-diagnostics

Conversation

@erantianantha

Copy link
Copy Markdown

Fixes #62436

Problem

When CommonSourceDirectory() is evaluated on a ParsedCommandLine (such as when calculating relative root/out directories across project references during resolution checks), outputpaths.GetCommonSourceDirectory was invoked with p.checkSourceFilesBelongToPath.

This caused ParsedCommandLine.Errors to be mutated with configuration diagnostics, which in turn caused tsc -b / solution builds to report diagnostics on tsconfig.json without source file location context.

Solution

  • Pass nil for checkSourceFilesBelongToPath in ParsedCommandLine.CommonSourceDirectory(), matching the TypeScript compiler reference implementation (getCommonSourceDirectoryOfConfig).
  • Added unit test coverage verifying that calling CommonSourceDirectory() computes the directory without mutating ParsedCommandLine.Errors.

Copilot AI balanced review requested due to automatic review settings September 7, 2026 20:04
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 7, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Sep 7, 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

The regression test currently passes against the pre-fix behavior because its source file is inside rootDir.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Prevents ParsedCommandLine.CommonSourceDirectory() from mutating configuration diagnostics.

Changes:

  • Removes the diagnostic-producing callback.
  • Adds a unit test for error immutability.
File summaries
File Description
tsc/internal/tsoptions/parsedcommandline.go Computes the common source directory without mutating errors.
tsc/internal/tsoptions/parsedcommandline_test.go Adds regression coverage, but its fixture does not trigger the prior mutation.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +246 to +252
"files": ["src/index.ts"]
}`)
parsedCommandLine := tsoptions.ParseJsonSourceFileConfigFileContent(
tsconfigSourceFile,
tsoptionstest.NewVFSParseConfigHost(map[string]string{
"/dev/src/index.ts": "",
}, "/dev", true),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

"This import path is unsafe to rewrite because it resolves to another project" missing an error location

3 participants