fix(tsoptions): don't mutate ParsedCommandLine errors when computing CommonSourceDirectory - #64193
Open
erantianantha wants to merge 1 commit into
Conversation
…CommonSourceDirectory Fixes microsoft#62436
Contributor
There was a problem hiding this comment.
🟡 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), |
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 #62436
Problem
When
CommonSourceDirectory()is evaluated on aParsedCommandLine(such as when calculating relative root/out directories across project references during resolution checks),outputpaths.GetCommonSourceDirectorywas invoked withp.checkSourceFilesBelongToPath.This caused
ParsedCommandLine.Errorsto be mutated with configuration diagnostics, which in turn causedtsc -b/ solution builds to report diagnostics ontsconfig.jsonwithout source file location context.Solution
nilforcheckSourceFilesBelongToPathinParsedCommandLine.CommonSourceDirectory(), matching the TypeScript compiler reference implementation (getCommonSourceDirectoryOfConfig).CommonSourceDirectory()computes the directory without mutatingParsedCommandLine.Errors.