Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 23x 23x 39x 57x 57x 23x | import type { DependencyGraph } from '../types';
/**
* Extract type dependencies from AST exports to build a type-based relationship graph.
*
* @param graph - The dependency graph to analyze.
* @returns Map of type reference names to sets of files that consume or export them.
*/
export function buildTypeGraph(
graph: DependencyGraph
): Map<string, Set<string>> {
const typeGraph = new Map<string, Set<string>>();
for (const [file, node] of graph.nodes) {
for (const exp of node.exports) {
Eif (exp.typeReferences) {
for (const typeRef of exp.typeReferences) {
if (!typeGraph.has(typeRef)) typeGraph.set(typeRef, new Set());
typeGraph.get(typeRef)!.add(file);
}
}
}
}
return typeGraph;
}
|