fix(js): follow tsconfig references so solution-file path aliases resolve (#3745) - #3753
Open
abhay-codes07 wants to merge 1 commit into
Open
abhay-codes07 wants to merge 1 commit into
abhay-codes07 wants to merge 1 commit into
Conversation
…esolve (Graphify-Labs#3745) `_read_tsconfig_aliases` walks `extends` chains but never `references`. In the standard Vite / `tsc -b` layout the root `tsconfig.json` is a solution file — `"files": []` with `references: [{path: "./tsconfig.app.json"}, …]` — and every `compilerOptions.paths` block lives in a referenced project config. The loader finds the solution file, sees no `paths` and no `extends`, and stops, so every path-alias import in the project silently produces no `imports_from` edge and `graphify affected` returns a partial consumer set with no warning. Follow `references` the same way `extends` is followed: merge each referenced config's aliases like an additional parent (the referencing config's own `paths` still override), guarded by the existing `seen` set that protects against cycles. A reference `path` may name a directory (resolved to its `tsconfig.json`, per `tsc -b`) or a config file directly. Regression tests cover both the solution-file layout and a directory-valued reference; both fail on the unpatched loader and pass with the fix. The existing JS/TS resolution, jsconfig-baseUrl, extension-resolution and Astro suites stay green (135 tests). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJbLfztSxm2tH5cJwBbe9q
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.
Fixes #3745.
What
_read_tsconfig_aliasesfollowsextendschains but neverreferences. In the standard Vite /tsc -blayout the roottsconfig.jsonis a solution file —"files": []withreferences: [{ "path": "./tsconfig.app.json" }, …]— and everycompilerOptions.pathsblock lives in a referenced project config. The loader walks up, finds the solution file, sees nopathsand noextends, and stops.The effect: every path-alias import in the project silently produces no
imports_fromedge. The specifier lands on a danglingref_*node, andgraphify affected <module>returns a partial consumer set with no warning. On the reporter's Vite + React app, 0 of 2,024 alias imports resolved (relative imports were 100%).Root cause
referencesis a first-class TypeScript project-linking mechanism, distinct fromextends._read_tsconfig_aliaseshandledextends(string or array) but thereferenceslist was never read, so a solution-style root yielded{}.Fix
After the
extendsloop, followreferencesthe same way: merge each referenced config's aliases like an additional parent (the referencing config's ownpathsstill override), guarded by the existingseenset that protectsextendsagainst cycles. A referencepathmay name a directory (resolved to itstsconfig.json, astsc -bdoes) or a config file directly.Verification
src/a.ts -imports_from-> ref_app_b(dangling); after,src/a.ts -imports_from-> src/b.ts(resolved).Notes
The prior attempt at this (#3631) was closed 2026-09-17 to be resubmitted and hasn't reappeared; this is an independent, minimal fix scoped to alias discovery.
replace-style edge cases (vendor/,go.workanalogues) don't apply to tsconfig; theseenguard makes the reference walk cycle-safe.