Skip to content

fix(js): follow tsconfig references so solution-file path aliases resolve (#3745) - #3753

Open
abhay-codes07 wants to merge 1 commit into
Graphify-Labs:v8from
abhay-codes07:fix/tsconfig-project-references
Open

abhay-codes07 wants to merge 1 commit into
Graphify-Labs:v8from
abhay-codes07:fix/tsconfig-project-references

Conversation

@abhay-codes07

@abhay-codes07 abhay-codes07 commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3745.

What

_read_tsconfig_aliases follows 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 walks up, finds the solution file, sees no paths and no extends, and stops.

The effect: every path-alias import in the project silently produces no imports_from edge. The specifier lands on a dangling ref_* node, and graphify 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

references is a first-class TypeScript project-linking mechanism, distinct from extends. _read_tsconfig_aliases handled extends (string or array) but the references list was never read, so a solution-style root yielded {}.

Fix

After the extends loop, follow references the same way: 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 extends against cycles. A reference path may name a directory (resolved to its tsconfig.json, as tsc -b does) or a config file directly.

Verification

  • Reproduced the minimal solution-file layout from the issue: before, src/a.ts -imports_from-> ref_app_b (dangling); after, src/a.ts -imports_from-> src/b.ts (resolved).
  • Two regression tests (solution-file reference, directory-valued reference) — both fail on the unpatched loader and pass with the fix.
  • No regressions: the JS/TS import-resolution, jsconfig-baseUrl, extension-resolution, and Astro suites stay green (135 tests).

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.work analogues) don't apply to tsconfig; the seen guard makes the reference walk cycle-safe.

…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
Copilot AI lite review requested due to automatic review settings September 22, 2026 17:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

tsconfig compilerOptions.paths behind a solution-file root ("files": [] + references) are never loaded — 0 of 2,024 alias imports get an edge

2 participants