Repository navigation
Description
Problem
_load_tsconfig_aliases() (extract.py) reads compilerOptions.paths from the
nearest tsconfig.json it finds, but does not follow the extends field.
This breaks alias resolution for any project that uses an extended tsconfig — which
is the modern default for SvelteKit, Nuxt, NestJS, Astro, T3 stack, and most
framework starters. In all of these, the user's tsconfig.json typically just
extends a framework-generated file, and the actual paths live in the parent.
The #575 fix works perfectly for projects that put paths directly in
tsconfig.json, but silently no-ops for the (much more common) extended case.
Repro
SvelteKit project (graphifyy 0.7.0).
tsconfig.json:
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": { ... } // no `paths`
}.svelte-kit/tsconfig.json (auto-generated by svelte-kit sync):
{
"compilerOptions": {
"paths": {
"$lib": ["../src/lib"],
"$lib/*": ["../src/lib/*"],
"$partials": ["../src/partials"],
"$partials/*": ["../src/partials/*"]
}
}
}Project code uses these aliases everywhere:
import { db } from '$lib/server/database'
import RecommendationCarousel from '$lib/components/recommendations/recommendation-carousel.svelte'Observed: _load_tsconfig_aliases() returns {} because the
project-root tsconfig.json has no paths. Every $lib/* and $partials/*
import falls into the bare-package branch and gets dropped.
Impact in numbers (1,966-file SvelteKit corpus, AST + Kimi semantic):
- 8,088 nodes, 11,179 edges built
- 1,705 communities (extreme fragmentation — most are 1-4 node singletons)
- 192
.sveltefiles appear with zero cross-file edges; ~150 of those are
verifiably used in the live app (cross-checked with knip + grep)
Root cause
extract.py _load_tsconfig_aliases():
data = json.loads(tsconfig.read_text(encoding="utf-8"))
paths = data.get("compilerOptions", {}).get("paths", {})
# never inspects data.get("extends")Proposed fix
Resolve the extends chain before reading paths. Pseudocode:
def _load_tsconfig_chain(path: Path, seen: set[Path] | None = None) -> dict:
"""Load a tsconfig and recursively merge from any `extends` parent.
Child paths win over parent. Cycle-safe via `seen`."""
seen = seen or set()
if path in seen or not path.exists():
return {}
seen.add(path)
data = json.loads(path.read_text(encoding="utf-8"))
extends = data.get("extends")
base = {}
if extends:
# extends can be relative path, absolute path, or a node-module name.
# For now handle the common relative-path case; node_modules resolution
# is a follow-up.
ext_path = (path.parent / extends).resolve()
if ext_path.is_dir():
ext_path = ext_path / "tsconfig.json"
elif ext_path.suffix == "":
ext_path = ext_path.with_suffix(".json")
base = _load_tsconfig_chain(ext_path, seen)
# Deep-merge compilerOptions; child paths override parent.
merged = {**base, **data}
base_co = base.get("compilerOptions", {})
own_co = data.get("compilerOptions", {})
merged["compilerOptions"] = {**base_co, **own_co}
if "paths" in own_co or "paths" in base_co:
merged["compilerOptions"]["paths"] = {**base_co.get("paths", {}), **own_co.get("paths", {})}
return mergedThen have _load_tsconfig_aliases() call _load_tsconfig_chain() and read
paths from the merged result.
Frameworks affected by this gap
- SvelteKit —
extends.svelte-kit/tsconfig.json - Nuxt 3/4 —
extends.nuxt/tsconfig.json - NestJS —
extendstsconfig.base.json - Astro —
extendsastro/tsconfigs/... - Anything from
tsconfig/bases(npm package) used by T3, monorepo templates - Most monorepo setups (turborepo, nx) where leaf packages extend a root tsconfig
Workaround
Manually copy the framework-generated paths into the project-root tsconfig.json.
Brittle (gets regenerated) and not always possible (SvelteKit overwrites
.svelte-kit/tsconfig.json on every svelte-kit sync).
Activity
safishamsi commentedon May 4, 2026
Fixed in v0.7.1. The alias resolver now follows the full
extendschain recursively, with circular detection. Aliases defined in a base config two levels up now resolve correctly for SvelteKit, Nuxt, and NestJS setups. Upgrade:pip install --upgrade graphifyy