Repository navigation
Description
Summary
The TS extractor emits an ordinary imports_from edge for type-only specifiers (import type / export type). TypeScript erases those at compile time and emits nothing at runtime, so any cycle that closes through them cannot exist.
On our repo (~7,900 nodes) this made 3 of 3 reported import cycles false. Since Import Cycles is a headline section of GRAPH_REPORT.md, that's a section we can't act on.
Related but distinct: #1193 is also a file-cycle false positive, but its cause is module names inside // comments. This one is about real import type statements being parsed correctly and then classified as runtime edges.
Minimal repro
Two files, nothing between them but type-only specifiers.
types.ts:
export type Variables = { requestId: string };
export type { RouterType } from "./v1.js";v1.ts:
import type { Variables } from "./types.js";
export type RouterType = { v: Variables };
export function makeRouter() { return {} as RouterType; }graphify extract . --code-only
graphify cluster-only . --no-label --no-vizActual
## Import Cycles
- 2-file cycle: `types.ts -> v1.ts -> types.ts`
Expected
No cycle. tsc emits no runtime import in either direction — both files' type-only specifiers are erased.
What it looked like on a real codebase
All three cycles reported for our API package:
2-file cycle: packages/api/src/types.ts -> v1.ts -> types.ts
3-file cycle: packages/api/src/inngest.ts -> middleware-stack.ts -> types.ts -> inngest.ts
3-file cycle: packages/api/src/middleware-stack.ts -> types.ts -> v1.ts -> middleware-stack.ts
Every edge closing those loops is type-only — types.ts lines 11–12 are export type { … } from "./v1.js" and "./inngest.js", and v1.ts:12, middleware-stack.ts:20, inngest.ts:9 are all import type { Variables } from "./types.js". The only runtime edges are v1 -> middleware-stack and inngest -> middleware-stack, and middleware-stack imports neither back.
The file even carries a comment saying the export type form was chosen deliberately for "zero runtime emit — no module graph cost". The tool reported the mitigation as the defect.
Suggested fix
Tag the edge rather than dropping it — the type dependency is real and useful for "what references this type", it just isn't a module-graph edge:
- emit a distinct relation (e.g.
imports_type), or keepimports_fromwith atype_only: trueattribute; - exclude type-only edges from cycle detection.
Worth noting the same conflation likely inflates affected in the other direction: a type-only importer is reported as impacted by a runtime change.
Both cases to cover: import type { X } from "…" and export type { X } from "…", plus inline import { type X } / export { type X }.
Environment
- graphify 0.9.50 (
uv tool install "graphifyy[sql]") - Python 3.14.5, macOS arm64
- TypeScript 5.x, pnpm workspace monorepo
Activity
fix(ts): type-only imports no longer manufacture Import Cycles (#3123)
chore: bump to 0.9.52
safishamsi commentedon Aug 29, 2026
Fixed in v0.9.52: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.52. Closing as resolved.
fix(python): keep TYPE_CHECKING-only imports out of import cycles (#3159