Slide 32
Slide 32 text
AST Transformation via TS
- TS Compiler APIʹΑΔ AST มίʔυ
- Try with Playground!
export function transform(src: ts.Node) {
const factory: ts.TransformerFactory = (ctx) => {
const visitor = (node: ts.Node): ts.Node | undefined => {
// ͜͜ʹ node ʹର͢ΔॲཧΛॻ͍͍ͯ͘
}
return (node) => ts.visitEachChild(node, visitor, ctx)
}
const result = ts.transform(src, [factory])
return result.transformed[0]
}