Skip to content

Instantly share code, notes, and snippets.

@arturovt
Created February 28, 2021 02:05
Show Gist options
  • Save arturovt/e60fdd4a1707cf9f7559b95504691bb7 to your computer and use it in GitHub Desktop.
Save arturovt/e60fdd4a1707cf9f7559b95504691bb7 to your computer and use it in GitHub Desktop.
import * as ts from 'typescript';
const transformerFactory: ts.TransformerFactory<ts.SourceFile> = (
context: ts.TransformationContext,
) => {
return (sourceFile: ts.SourceFile) => {
const someVisitFunction: ts.Visitor = (node: ts.Node) => {
if (ts.isFunctionDeclaration(node)) {
console.log('Whooah, it is a function declaration!');
}
return ts.visitEachChild(node, someVisitFunction, context);
};
return ts.visitEachChild(sourceFile, someVisitFunction, context);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment