问题
Is there a way to parse a TypeScript file to an AST, modify the AST, and parse it then back to TypeScript as the tools Esprima + Escodegen are able to?
Important is that I do NOT want to compile/transpile the TypeScript code first into JavaScript.
回答1:
Yes, with Typescript 2.x you can transform ast. Here is a good blog post about it http://blog.scottlogic.com/2017/05/02/typescript-compiler-api-revisited.html. In the official typescript wiki it is not well documented yet.
来源:https://stackoverflow.com/questions/39917907/typescript-ast-typescript