-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use AST instead of ejs templates for generators #2113
Comments
In my experience, I find templates much easier to read and reason about, because they resemble the actual source code produced. However, I am open to experimentation! Would you like to create a proof-of-concept pull request showing how to use an AST-based template in one of our
Modification of existing code is a different task, it was never our intention to use templates for that. Based on the discussion in #1656, we may use |
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
@bajtos |
looks like this issue was covered, mostly with #2426 , closing now, please open a new issue for additional topics. |
I think it would be better to generate code from an abstract syntax tree rather than using templates.
In the past, I have found the
@babel/generator
to be a solid choice for generating code from AST, however, that would not work for typescript. Perhaps, thegetTextOfNode()
method in the typescript compiler utilities would do the job.https://github.com/Microsoft/TypeScript/blob/aa3734c14834afb454c49bc956489980d990a765/src/compiler/utilities.ts#L503
This is definitely a much more flexible approach because it conforms to the user's style of choice. It also allows for dynamically modifying existing files without the huge risk of destroying code.
The text was updated successfully, but these errors were encountered: