Skip to content

fix(goport): names under a drive-like dir print absolute, as Go - #115

Open
THEtheChad wants to merge 1 commit into
pingdotgg:mainfrom
THEtheChad:fix/drive-like-segment-path
Open

THEtheChad wants to merge 1 commit into
pingdotgg:mainfrom
THEtheChad:fix/drive-like-segment-path

Conversation

@THEtheChad

Copy link
Copy Markdown

When a file sits under a directory literally named like a drive (c:), tsc-rs prints c:/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 --explainFiles and tsc -b --verbose. Repro: a tsconfig with "files":["c:/root/a.ts"] whose import "file4" resolves to c:/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, and c:/... has a DOS root. The port's diagnostic writer, the second WriteFormatDiagnostic port in program.rs and the tsc -b orchestrator still used ConvertToRelativePath, and the --explainFiles helper checked only for a different root.

Fix: port formatFileNameRelativeTo (diagnosticwriter.go:27) and route these sites through relative_path_from_directory, the existing port of Go's function. Only a one-letter segment followed by : is affected; x:y and ab:c already matched.

Tests: tsctests/drive_like_segment_path.rs runs tsgo in 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, including C:, nested z: and ../../C:/ variants.

Not in this PR: .tsbuildinfo still differs for this case (Go writes missingPackageJsons as absolute paths there). That is a separate subsystem (snapshottobuildinfo.go:71-92) and gets its own PR.

🤖 Generated with Claude Code

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>
@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: afb5a291-8fd4-428d-a08b-0dd868f8d57d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant