You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeScript ESM imports spelled ./x.js never resolve to x.ts (import-graph recall 0.2% on zod) #3552
Modern TypeScript under "moduleResolution": "node16"/"nodenext", and every ESM package published from TS, imports a sibling source file by its emitted name: import { metabench } from "./metabench.js" refers to metabench.ts. The TypeScript compiler maps .js → .ts, .jsx → .tsx, .mjs → .mts and .cjs → .cts. The engine's import resolver doesn't, so these imports draw no edge at all.
Measured
tests/tools/import_graph_accuracy.py, merged in #3547, pinned corpus colinhacks/zod@2bf7b06:
resolvable imports
engine edges
precision
recall
599
53
1.9%
0.2%
Nearly all 598 misses are this shape. Examples, checked against the source:
packages/bench/array.ts: import { makeData, … } from "./benchUtil.js" → packages/bench/benchUtil.ts, no edge.
packages/zod/src/v4/core/schemas.ts: import * as checks from "./checks.js" → checks.ts, no edge.
The 52 edges the engine does draw from these files mostly come from bare package specifiers ("zod/v4/core") matched by basename. For example, packages/bench/*.ts → packages/zod/src/v4/core/core.ts is the #3544 shape.
Impact
For any ESM TypeScript project, the import graph is nearly empty. So PageRank, blast radius, popularity and dependency_density for TS files come out almost entirely wrong. JS projects written as ESM with explicit extensions resolve normally; this is TS-specific.
Fix direction
In network_risk_sensor.py's resolver, for a relative (./ or ../) token whose extension is .js/.jsx/.mjs/.cjs, also try the TS source extensions at the same path (.ts, .tsx, .mts, .cts, .d.ts) after the literal path. Only for relative tokens: a bare specifier stays a package.
Gate:import_graph_accuracy.py typescript should move by hundreds of edges. Lock the gain in with --regenerate, and re-bless golden masters for the TS corpus moves.
Fixed by #3562 (merged). A ./x.js ESM import now resolves to its x.ts source, and an existing x.js file still takes precedence. On zod, TypeScript import-graph recall went from 0.2% to 100%, with 91.4% precision. CI gates both through import_graph_accuracy.py.
Activity
fix(network): resolve imports by each language's own rule (#3544 #3545 …
fix(network): resolve imports by each language's own rule (#3544 #3545 …
squid-protocol commentedon Sep 25, 2026
Fixed by #3562 (merged). A
./x.jsESM import now resolves to itsx.tssource, and an existingx.jsfile still takes precedence. On zod, TypeScript import-graph recall went from 0.2% to 100%, with 91.4% precision. CI gates both throughimport_graph_accuracy.py.Generated by Claude Code