MCPcopy Index your code
hub / github.com/nodejs/node / visitImportDeclaration

Function visitImportDeclaration

test/fixtures/snapshot/typescript.js:93809–93828  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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 *

Callers 2

visitElidableStatementFunction · 0.85
topLevelVisitorFunction · 0.85

Calls 7

createRequireCallFunction · 0.85
hoistVariableDeclarationFunction · 0.85
pushMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected