MCPcopy Create free account
hub / github.com/nodejs/node / visitNamedImportBindings

Function visitNamedImportBindings

test/fixtures/snapshot/typescript.js:93846–93858  ·  view source on GitHub ↗

* Visits named import bindings, eliding them if their targets, their references, and the compilation settings allow. * * @param node The named import bindings node.

(node)

Source from the content-addressed store, hash-verified

93844 * @param node The named import bindings node.
93845 */
93846 function visitNamedImportBindings(node) {
93847 if (node.kind === 268 /* SyntaxKind.NamespaceImport */) {
93848 // Elide a namespace import if it is not referenced.
93849 return shouldEmitAliasDeclaration(node) ? node : undefined;
93850 }
93851 else {
93852 // Elide named imports if all of its import specifiers are elided and settings allow.
93853 var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ ||
93854 compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */);
93855 var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier);
93856 return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined;
93857 }
93858 }
93859 /**
93860 * Visits an import specifier, eliding it if its target, its references, and the compilation settings allow.
93861 *

Callers

nothing calls this directly

Calls 2

someMethod · 0.80

Tested by

no test coverage detected