( source: ts.SourceFile, classifiedName: string, importPath: string, )
| 545 | * Determine if an import already exists. |
| 546 | */ |
| 547 | export function isImported( |
| 548 | source: ts.SourceFile, |
| 549 | classifiedName: string, |
| 550 | importPath: string, |
| 551 | ): boolean { |
| 552 | const allNodes = getSourceNodes(source); |
| 553 | const matchingNodes = allNodes |
| 554 | .filter(ts.isImportDeclaration) |
| 555 | .filter( |
| 556 | (imp) => ts.isStringLiteral(imp.moduleSpecifier) && imp.moduleSpecifier.text === importPath, |
| 557 | ) |
| 558 | .filter((imp) => { |
| 559 | if (!imp.importClause) { |
| 560 | return false; |
| 561 | } |
| 562 | const nodes = findNodes(imp.importClause, ts.isImportSpecifier).filter( |
| 563 | (n) => n.getText() === classifiedName, |
| 564 | ); |
| 565 | |
| 566 | return nodes.length > 0; |
| 567 | }); |
| 568 | |
| 569 | return matchingNodes.length > 0; |
| 570 | } |
| 571 | |
| 572 | /** |
| 573 | * Returns the RouterModule declaration from NgModule metadata, if any. |
nothing calls this directly
no test coverage detected