/** * @fileoverview Project-wide import graph builder. * * Builds a file-level dependency graph from a set of TypeScript/JavaScript * source files, plus a Tarjan's strongly-connected-components implementation * for cycle detection. Used by structural-drift checks like * circular-import-detection and module-coupling-fan-out. * * Module resolution is deliberately a heuristic: relative imports are * resolved by trying common extension/index.ts suffixes; bare specifiers * (npm packages) are dropped; tsconfig path aliases are NOT resolved * (treated as unresolved — they simply don't appear as edges in the graph). * * This matches the heuristic the existing `phantom-dependency-detection` * check uses, which has been shipping reliably. Adding tsconfig-aware * resolution is a follow-up plan. */ /** A file-level import graph for a project. */ export interface ImportGraph { /** All node file paths (absolute, as supplied by the caller). */ readonly nodes: ReadonlySet; /** Adjacency: file → set of files it imports (intra-project edges only). */ readonly outbound: ReadonlyMap>; /** Reverse adjacency: file → set of files that import it. */ readonly inbound: ReadonlyMap>; } /** * Build an import graph from a collection of file paths and their content. * * Each file's TS AST is walked for top-level `import` and `export ... from` * declarations. Relative specifiers (`./foo`, `../bar/baz.js`) are resolved * against the importing file's directory using the heuristic in * `resolveRelativeSpecifier`. Bare specifiers (`react`, `lodash`) are * dropped — they don't represent intra-project edges. * * Files that fail to parse are still added as nodes (with no edges) so the * graph remains complete. */ export declare function buildImportGraph(files: ReadonlyMap): ImportGraph; /** * Find strongly-connected components in the graph using Tarjan's algorithm. * * Returns an array of SCCs, each represented as an array of node names. SCCs * of size 1 represent a node with no cycle (or a self-loop, which is rare in * import graphs). Cycle-detection callers typically filter to `scc.length > 1` * to get only real multi-file cycles. * * Algorithm: standard iterative Tarjan's SCC. O(V + E), single pass. */ export declare function findStronglyConnectedComponents(graph: ImportGraph): readonly (readonly string[])[]; //# sourceMappingURL=import-graph.d.ts.map