Skip to content

fix(compiler): report TS1006 for a self reference without an extension - #1023

Merged
camc314 merged 1 commit into
oxc-project:mainfrom
magurotuna:fix/self-reference-without-extension
Nov 18, 2026
Merged

camc314 merged 1 commit into
oxc-project:mainfrom
magurotuna:fix/self-reference-without-extension

Conversation

@magurotuna

Copy link
Copy Markdown
Member

What and why

When a.ts contains /// <reference path="a" />, tsgo reports TS1006 ("A file cannot have a reference to itself.") and exits 2. tsrs reported nothing and exited 0, and --explainFiles listed the self reference as a reason.

tsrs checked for a self reference only when the name already had an extension. A name that got its extension in the lookup loop skipped the check. The check now runs after every successful lookup in resolve_tripleslash_path_reference, as Go resolveTripleslashPathReference does.

Evidence

  • New regression case reference-path-self-without-extension, with expected output from tsgo: fails on main and passes with the fix. tools/regressions.sh: 55/55 pass.
  • tsrs_compiler tests: 35 passed. recycle_checkers: passed.
  • Clippy for tsrs_compiler, cargo fmt --check and node tools/lint/source.mjs: clean.
  • tsrs-test run --suite all --timeout 300: the same 13,696 tests pass as on main.

AI assistance: written with Claude Code.

A file `a.ts` with `/// <reference path="a" />` gave no diagnostic and exit
status 0, but tsgo reports TS1006 and exits 2. The Rust port checked for a
self reference inside `source_file_from_reference`, but only in the branch
for a name that already has an extension. The supported-extensions loop and
the `allowNonTsExtensions` branch returned the candidate without the check.

Port the Go order from `resolveTripleslashPathReference`
(`fileloader.go:753`): `getSourceFileFromReference` only looks up the file,
and the caller compares the containing path with the resolved path after
every successful lookup. Both lookup paths (single-threaded and the parallel
prefetch) go through `resolve_tripleslash_path_reference`, so both get the
check.

Tests: the regression case `reference-path-self-without-extension`, with
expected output from tsgo at the pinned commit.

AI assistance: written with Claude Code.
@codspeed

codspeed Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

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/self-reference-without-extension (38bd9d7) with main (7eb504d)

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 18, 2026
Merged via the queue into oxc-project:main with commit 5c06005 Nov 18, 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