Repository navigation
fix(compiler): report TS1006 for a self reference without an extension - #1023
Merged
camc314 merged 1 commit intoNov 18, 2026
Merged
Conversation
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.
Contributor
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
camc314
approved these changes
Nov 18, 2026
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.
What and why
When
a.tscontains/// <reference path="a" />, tsgo reports TS1006 ("A file cannot have a reference to itself.") and exits 2. tsrs reported nothing and exited 0, and--explainFileslisted 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 GoresolveTripleslashPathReferencedoes.Evidence
reference-path-self-without-extension, with expected output from tsgo: fails onmainand passes with the fix.tools/regressions.sh: 55/55 pass.tsrs_compilertests: 35 passed.recycle_checkers: passed.tsrs_compiler,cargo fmt --checkandnode tools/lint/source.mjs: clean.tsrs-test run --suite all --timeout 300: the same 13,696 tests pass as onmain.AI assistance: written with Claude Code.