Skip to content

fix(checker): name the absolute file in TS2876 for a file below ^/ - #1111

Merged
camc314 merged 1 commit into
oxc-project:mainfrom
magurotuna:fix/checker-rewrite-check-rooted-relative-path
Nov 26, 2026
Merged

camc314 merged 1 commit into
oxc-project:mainfrom
magurotuna:fix/checker-rewrite-check-rooted-relative-path

Conversation

@magurotuna

Copy link
Copy Markdown
Member

With rewriteRelativeImportExtensions, TS2876 named a file below a directory named ^ with a relative path that starts with ^/:

// a.ts: import "./^/x.ts";   (^/x.ts/index.ts exists)
tsgo: error TS2876: ... but actually resolves to "<dir>/^/x.ts/index.ts".
tsrs: error TS2876: ... but actually resolves to "^/x.ts/index.ts".

Go resolveExternalModule uses RelativePathFromFile, which returns false when the result starts with a root, and then keeps the absolute name. tsrs had no such check. This PR uses tspath::relative_path_from_file_to_path there. The TS2878 check below it has the same cause; #1100 fixes that one.

Tests: the rewrite-check-caret-directory regression.

AI assistance: written with Claude Code.

With `rewriteRelativeImportExtensions`, TS2876 named a file below a
directory named `^` with a relative path that starts with `^/`:

```
// a.ts: import "./^/x.ts";   (^/x.ts/index.ts exists)
tsgo: error TS2876: ... but actually resolves to "<dir>/^/x.ts/index.ts".
tsrs: error TS2876: ... but actually resolves to "^/x.ts/index.ts".
```

Go `resolveExternalModule` (`checker/checker.go:15600`) uses
`RelativePathFromFile`, which returns `false` when the result starts with a
root, and then keeps the absolute name. tsrs had no such check. Use
`tspath::relative_path_from_file_to_path` there. The TS2878 check below it
has the same cause; oxc-project#1100 fixes that one.

Tests: the `rewrite-check-caret-directory` regression.

AI assistance: written with Claude Code.
@codspeed

codspeed Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

Warning

oxc-project has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed.

1 warning

⚠️ 4 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

βœ… 8 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing magurotuna:fix/checker-rewrite-check-rooted-relative-path (1ddc3d3) with main (9fb8d5a)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@camc314
camc314 added this pull request to the merge queue Nov 26, 2026
Merged via the queue into oxc-project:main with commit 46c8496 Nov 26, 2026
71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants