Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const exportName = nodeRequest.name;
declarations.push({name: exportName, node, order: DeclarationOrder.BeforeStmt});
return ts.createIdentifier(exportName);
}
let result = node;
if (shouldVisit(pos, end) && !isLexicalScope(node)) {
result = ts.visitEachChild(node, visitNode, context);
}
return result;
}
// Get the original node before tsickle
const {pos, end} = ts.getOriginalNode(node);
let resultStmt: ts.Statement;
if (shouldVisit(pos, end)) {
resultStmt = ts.visitEachChild(node, visitNode, context);
} else {
resultStmt = node;
}
if (declarations.length) {
inserts.push({relativeTo: resultStmt, declarations});
}
return resultStmt;
}
function transformClassElement(element: ts.ClassElement):
[string|undefined, ts.ClassElement, ts.Decorator[]] {
element = ts.visitEachChild(element, visitor, context);
const decoratorsToKeep: ts.Decorator[] = [];
const toLower: ts.Decorator[] = [];
for (const decorator of element.decorators || []) {
if (!shouldLower(decorator, typeChecker)) {
decoratorsToKeep.push(decorator);
continue;
}
toLower.push(decorator);
}
if (!toLower.length) return [undefined, element, []];
if (!element.name || element.name.kind !== ts.SyntaxKind.Identifier) {
// Method has a weird name, e.g.
// [Symbol.foo]() {...}
diagnostics.push({
file: element.getSourceFile(),
if (ts.isImportDeclaration(node)) {
// Found an 'import ...' declaration
const importedModuleId: string = findModuleIdFromImport(node);
analyser(node.getSourceFile(), importedModuleId);
} else if (ts.isExportDeclaration(node) && node.moduleSpecifier) {
// Found an 'export ... from ...' declaration
const importedModuleId: string = findModuleIdFromExport(node);
analyser(node.getSourceFile(), importedModuleId);
} else {
return ts.visitEachChild(node, visitImports, context);
}
return node;
};
return ts.visitEachChild(sourceFile, visitImports, context);
};
const newImportString = `./${forwardSlashPath(relativePath)}`.replace(/ts$/, 'ngfactory');
// The easiest way to alter them is with a simple visitor.
const replacementVisitor: ts.Visitor = (node: ts.Node) => {
if (node === importStringLit) {
// Transform the import string.
return ts.createStringLiteral(newImportString);
} else if (node === exportNameId) {
// Transform the export name.
return ts.createIdentifier(exportNameId.text + 'NgFactory');
}
return ts.visitEachChild(node, replacementVisitor, context);
};
return ts.visitEachChild(node, replacementVisitor, context);
}
const visit: ts.Visitor = node => visitor(node) ?? ts.visitEachChild(node, visit, context);
return ts.visitNode(node, visit);
function visit(node: ts.Node, cmpMeta: ComponentMeta): ts.VisitResult {
switch (node.kind) {
case ts.SyntaxKind.ClassDeclaration:
return visitClass(node as ts.ClassDeclaration, cmpMeta);
default:
return ts.visitEachChild(node, (node) => {
return visit(node, cmpMeta);
}, transformContext);
}
}
);
return ts.createCall(
ts.createPropertyAccess(n as ts.Expression, 'withConfig'),
undefined,
[ts.createObjectLiteral(styledConfig)],
);
}
ts.forEachChild(n, m => {
if (!m.parent) {
m.parent = n;
}
});
return ts.visitEachChild(n, visitor, context);
};
const pass = () => ts.visitEachChild(node, visitor, ctx);
const visitNode = (node: ts.Node): ts.Node => {
if (ts.isMethodDeclaration(node)) {
return this.addDecoratorToNode(node, typeChecker, sourceFile.fileName);
}
return ts.visitEachChild(node, visitNode, ctx);
};
return ts.visitNode(sourceFile, visitNode);
function visitEnsureConstructor(node: ts.Node): ts.VisitResult {
if (ts.isClassDeclaration(node)) {
return ts.visitEachChild(
appendConstructor(node as ts.ClassDeclaration),
visitEnsureConstructor,
transformContext
)
}
return ts.visitEachChild(node, visitEnsureConstructor, transformContext)
}