Function transformer
- transformer(
handler: (
data: {
context: TransformationContext;
node: Node;
sourceFile: SourceFile;
},
) => any,
postHandler?: (sourceFile: SourceFile) => SourceFile,
): TransformerFactory<SourceFile | Bundle>Parameters
- handler: (
data: {
context: TransformationContext;
node: Node;
sourceFile: SourceFile;
},
) => anyA function to process AST nodes.
OptionalpostHandler: (sourceFile: SourceFile) => SourceFileA function to postprocess the source file after all nodes visited. Return an updated SourceFile node.
Returns TransformerFactory<SourceFile | Bundle>
JSDoc custom "meta-transformer".
- handler: (
Provides a convenient "meta-transformer" that invokes a handler function for each Node reducing the boilerplate required.
Note: In the
handlerreturn null to remove the Node. ThepostHandlerallows final modification of the SourceFile after all nodes are visited; return a new SourceFile to update it.