Repository navigation
fix(goport): names under a drive-like dir print absolute, as Go - #115
Open
THEtheChad wants to merge 1 commit into
Open
THEtheChad wants to merge 1 commit into
THEtheChad wants to merge 1 commit into
Conversation
Go (ts#64159) prints a file name relative to the current directory with RelativePathFromDirectory, which falls back to the absolute name when the relative name looks rooted. Under a directory literally named `c:`, `<cwd>/c:/a.ts` is `c:/a.ts` relative, a DOS root, so Go prints `<cwd>/c:/a.ts`. The port still used ConvertToRelativePath in the diagnostic writer (diagnosticwriter.go:27 formatFileNameRelativeTo, used by WriteLocation, prettyPathForFileError and WriteFormatDiagnostic) and in `tsc -b` (orchestrator.go:94 relativeFileName), and `--explainFiles` (program.go:2159, fileInclude.go:155) checked only for another root, so it printed `c:/a.ts`. The fuzzer found it through a module whose real path is under `<cwd>/c:/`. All of them now call relative_path_from_directory, the port of RelativePathFromPath. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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.
When a file sits under a directory literally named like a drive (
c:), tsc-rs printsc:/node_modules/file4/index.d.ts(1,5): ...where Go prints<cwd>/c:/node_modules/file4/index.d.ts(1,5): .... The same goes for--explainFilesandtsc -b --verbose. Repro: a tsconfig with"files":["c:/root/a.ts"]whoseimport "file4"resolves toc:/node_modules/file4/index.d.ts, which contains an error.Cause: since microsoft/TypeScript#64159, Go prints names with
RelativePathFromDirectory(tspath/relative_path.go:82). It falls back to the absolute name when the relative result looks rooted, andc:/...has a DOS root. The port's diagnostic writer, the secondWriteFormatDiagnosticport inprogram.rsand thetsc -borchestrator still usedConvertToRelativePath, and the--explainFileshelper checked only for a different root.Fix: port
formatFileNameRelativeTo(diagnosticwriter.go:27) and route these sites throughrelative_path_from_directory, the existing port of Go's function. Only a one-letter segment followed by:is affected;x:yandab:calready matched.Tests:
tsctests/drive_like_segment_path.rsrunstsgoin a temp dir: the repro with--explainFiles, pretty output and its summary, and-b --verbose. Output and exit code are byte-identical to Go tsc at 3e9236361fa9, includingC:, nestedz:and../../C:/variants.Not in this PR:
.tsbuildinfostill differs for this case (Go writesmissingPackageJsonsas absolute paths there). That is a separate subsystem (snapshottobuildinfo.go:71-92) and gets its own PR.🤖 Generated with Claude Code