How to use the createImportDeclaration function from typescript
Find comprehensive JavaScript typescript.createImportDeclaration code examples handpicked from public code repositorys.
74 75 76 77 78 79 80 81 82 83
} else { // Create the new import node. const namedImports = ts.createNamedImports([ts.createImportSpecifier(undefined, ts.createIdentifier(symbolName))]); const importClause = ts.createImportClause(undefined, namedImports); const newImport = ts.createImportDeclaration(undefined, undefined, importClause, ts.createLiteral(modulePath)); if (allImports.length > 0) { // Find the last import and insert after. ops.push(new interfaces_1.AddNodeOperation(sourceFile, allImports[allImports.length - 1], undefined, newImport)); }
0
0
1
42 43 44 45 46 47 48 49 50 51
relativePath = `./${relativePath}`; } // Create the new namespace import node. const namespaceImport = ts.createNamespaceImport(ts.createIdentifier(`__lazy_${index}__`)); const importClause = ts.createImportClause(undefined, namespaceImport); const newImport = ts.createImportDeclaration(undefined, undefined, importClause, ts.createLiteral(relativePath)); const firstNode = ast_helpers_1.getFirstNode(sourceFile); if (firstNode) { ops.push(new interfaces_1.AddNodeOperation(sourceFile, firstNode, newImport)); }
0
0
1
typescript.SyntaxKind is the most popular function in typescript (82777 examples)