You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
is there an example of how to transform AST of a file and emit it? #7580
No, not yet... the team have been burning the midnight oil to get it into master. If you don't feel comfortable spelunking in the source code for TypeScript, I think you are going to have to wait a while until there is any sort of decent documentation. Likely though, especially when it comes to using the services and other internals of TypeScript, it is really up to the wider community to start providing the "how to" instead of official documentation.
We do not currently expose the transformation API as part of the language service. This is something we are considering. Once we make it available as a public API we will provide documentation on its use.
i think he said that it is in private api that isnt exposed to public, can you use private API of TypeScript? sure, just take a full ownership of it meaning write your code right in it or modify it so that it is public
here is a list of all code cjanges related to AST transformations, at this point i'd say there is no better way to learn it other than by looking at what was done
We do not currently expose the transformation API as part of the language service. This is something we are considering. Once we make it available as a public API we will provide documentation on its use.
Ron Buckton (@rbuckton) Is there an entry on the roadmap for making the AST transformation API public? Or can you estimate when this will happen?
Activity
zpdDG4gta8XKpMCd commentedon Mar 18, 2016
another example is enforcing curly braces on if statements and such:
DanielRosenwasser commentedon Mar 18, 2016
Ideally you could do this with #5595 (see also #3241), but until we have an API for that, you can use our language service API.
Then:
Something like this might work:
Don't hold me to it though, I haven't tested it out yet.
DanielRosenwasser commentedon Mar 18, 2016
Also check out https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#pretty-printer-using-the-ls-formatter
wclr commentedon Sep 4, 2016
Is it possible now to make source transformation using alternations in AST not via text replacement as shown?
kitsonk commentedon Sep 4, 2016
When #5595 lands, yes... it should be in master soon
wclr commentedon Sep 7, 2016
So #5595 seem to land? Is there some docs/info about transforming AST?
kitsonk commentedon Sep 7, 2016
No, not yet... the team have been burning the midnight oil to get it into master. If you don't feel comfortable spelunking in the source code for TypeScript, I think you are going to have to wait a while until there is any sort of decent documentation. Likely though, especially when it comes to using the services and other internals of TypeScript, it is really up to the wider community to start providing the "how to" instead of official documentation.
wclr commentedon Sep 7, 2016
Kitson Kelly (@kitsonk) Ok, thanks for response) I'm quite comfortable with source/tests code. Here is what I want to do:
ts.createSourceFile)Are step 3-5 possible now? If yest could you direct to the source that should be investigated?
rbuckton commentedon Sep 8, 2016
We do not currently expose the transformation API as part of the language service. This is something we are considering. Once we make it available as a public API we will provide documentation on its use.
wclr commentedon Sep 8, 2016
Ron Buckton (@rbuckton) so it is not possible at all? ok can be hacked around?
zpdDG4gta8XKpMCd commentedon Sep 8, 2016
i think he said that it is in private api that isnt exposed to public, can you use private API of TypeScript? sure, just take a full ownership of it meaning write your code right in it or modify it so that it is public
wclr commentedon Sep 8, 2016
Ok, I get it, now I ask where to look for this private API in particular?
zpdDG4gta8XKpMCd commentedon Sep 8, 2016
here is a list of all code cjanges related to AST transformations, at this point i'd say there is no better way to learn it other than by looking at what was done
zpdDG4gta8XKpMCd commentedon Sep 8, 2016
https://github.com/Microsoft/TypeScript/issues?utf8=✓&q=is%3Amerged%20label%3A"Domain%3A%20Transforms"%20
cape-dev commentedon Oct 13, 2016
Ron Buckton (@rbuckton) Is there an entry on the roadmap for making the AST transformation API public? Or can you estimate when this will happen?
Renamed in favour of (@whitecolor) Did you find a way to achieve your goals?
wclr commentedon Oct 19, 2016
@kamekazemaster no i didn't look close yet