* Visits an import declaration, eliding it if it is type-only or if it has an import clause that may be elided. * * @param node The import declaration node.
(node)
| 93807 | * @param node The import declaration node. |
| 93808 | */ |
| 93809 | function visitImportDeclaration(node) { |
| 93810 | if (!node.importClause) { |
| 93811 | // Do not elide a side-effect only import declaration. |
| 93812 | // import "foo"; |
| 93813 | return node; |
| 93814 | } |
| 93815 | if (node.importClause.isTypeOnly) { |
| 93816 | // Always elide type-only imports |
| 93817 | return undefined; |
| 93818 | } |
| 93819 | // Elide the declaration if the import clause was elided. |
| 93820 | var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); |
| 93821 | return importClause || |
| 93822 | compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || |
| 93823 | compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ |
| 93824 | ? factory.updateImportDeclaration(node, |
| 93825 | /*decorators*/ undefined, |
| 93826 | /*modifiers*/ undefined, importClause, node.moduleSpecifier, node.assertClause) |
| 93827 | : undefined; |
| 93828 | } |
| 93829 | /** |
| 93830 | * Visits an import clause, eliding it if its `name` and `namedBindings` may both be elided. |
| 93831 | * |
no test coverage detected