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

Function updateNamespaceLikeImportNode

test/fixtures/snapshot/typescript.js:162201–162216  ·  view source on GitHub ↗
(node, newNamespaceName, newModuleSpecifier)

Source from the content-addressed store, hash-verified

162199 }
162200 }
162201 function updateNamespaceLikeImportNode(node, newNamespaceName, newModuleSpecifier) {
162202 var newNamespaceId = ts.factory.createIdentifier(newNamespaceName);
162203 var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier);
162204 switch (node.kind) {
162205 case 266 /* SyntaxKind.ImportDeclaration */:
162206 return ts.factory.createImportDeclaration(
162207 /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString,
162208 /*assertClause*/ undefined);
162209 case 265 /* SyntaxKind.ImportEqualsDeclaration */:
162210 return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString));
162211 case 254 /* SyntaxKind.VariableDeclaration */:
162212 return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString));
162213 default:
162214 return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind));
162215 }
162216 }
162217 function moduleSpecifierFromImport(i) {
162218 return (i.kind === 266 /* SyntaxKind.ImportDeclaration */ ? i.moduleSpecifier
162219 : i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? i.moduleReference.expression

Callers 1

Calls 2

createRequireCallFunction · 0.85
concatMethod · 0.80

Tested by

no test coverage detected