MCPcopy Create free account
hub / github.com/angular/dev-infra / getModuleReferences

Function getModuleReferences

ng-dev/ts-circular-dependencies/parser.ts:16–42  ·  view source on GitHub ↗
(
  initialNode: ts.SourceFile,
  ignoreTypeOnlyChecks: boolean,
)

Source from the content-addressed store, hash-verified

14 * @returns List of import specifiers in the source file.
15 */
16export function getModuleReferences(
17 initialNode: ts.SourceFile,
18 ignoreTypeOnlyChecks: boolean,
19): string[] {
20 const references: string[] = [];
21 const visitNode = (node: ts.Node) => {
22 if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
23 // When ignoreTypeOnlyChecks are enabled, if the declaration is found to be type only, it is skipped.
24 if (
25 ignoreTypeOnlyChecks &&
26 ((ts.isImportDeclaration(node) && node.importClause?.isTypeOnly) ||
27 (ts.isExportDeclaration(node) && node.isTypeOnly))
28 ) {
29 return;
30 }
31
32 if (node.moduleSpecifier !== undefined && ts.isStringLiteral(node.moduleSpecifier)) {
33 references.push(node.moduleSpecifier.text);
34 }
35 }
36 ts.forEachChild(node, visitNode);
37 };
38
39 ts.forEachChild(initialNode, visitNode);
40
41 return references;
42}

Callers 1

findCyclesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected