TyrealHu / acorn-typescript

Alternative, TypeScript parser
https://www.npmjs.com/package/acorn-typescript?activeTab=readme
MIT License
145 stars 18 forks source link

Which types to use while processing ASTs? #60

Open manuel3108 opened 2 months ago

manuel3108 commented 2 months ago

When using normal acorn we have the possibility to use @types/estree while processing the ast to get some kind of type safety. Of course this only works if the processing happens on a TS or JSDOC project, but that's on another note.

We would like to do some AST post processing with this library in a type safe manner. Sadly @types/estree does not contain any relevant information about the TS nodes, and such does the specification.

So the first question is: Based on which specification are the TS nodes emitted by this tool generated?

The closest tool I could find that also publishes estree specific TS Nodes to it's ast is @typescript-eslint/types. Annoyingly they have some minor but noticeable differences that make working with types pretty annoying.

I also had a look at this project's source code, but for me it looks like the generated nodes are mainly untyped. Is that correct, or am I just missing some post checkout steps?

And that's where my second question comes into play: Are you aware of any defined types that properly represent the AST Nodes generated by this project?