TypeScript -> AST -> TypeScript

余生颓废 提交于 2019-12-23 10:00:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!