Skip to content
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

Add a way to get a typed AST #16692

Closed
jslegers opened this issue Jun 22, 2017 · 5 comments
Closed

Add a way to get a typed AST #16692

jslegers opened this issue Jun 22, 2017 · 5 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@jslegers
Copy link

jslegers commented Jun 22, 2017

I understand that TypeScript is not intented to be compiled to eg. asm.js or C/C++, but the ability to export a language like Flow or TypeScript to typed AST in some way or another would allow another team of developers to use that as a basis for "TypeScript to C/C++", "TypeScript to asm.js" or "TypeScript to whatever" conversions, as suggested in this issue for Flow.

The short term benefit would obviously be small, but the large term benefit would be quite significant, as it would basically provide a pluggable interface that allows (subsets of?) TypeScript to be converted to any language that is sufficiently compatible. In theory, it would allow TypeScript - when combined with third party plug-ins" - to be used as some kind of "convert to anything" kind of language, which is what many people are trying to use JavaScript for but for which JavaScript (due to the lack of static typing) happens to be less suitable than TypeScript or Flow. And this, with - I imagine - little effort from the TypeScript core devs, as exporting the typed AST that is used internally would be all they would have to do to make this possible.

Is there any chance you might consider exporting the typed AST?

@kitsonk
Copy link
Contributor

kitsonk commented Jun 22, 2017

You can access the AST, including all the types, via the language services, and you can then in theory emit whatever you wanted.

@jslegers
Copy link
Author

@kitsonk

Now, that's interesting. Can you think of any online source that to recommend on accessing the AST through the language services?
As far as I can tell, the official docs are very limited...

@kitsonk
Copy link
Contributor

kitsonk commented Jun 22, 2017

This has the best official examples, but yes, the documentation is not overly strong. Taking a look at vscode's integration can be helpful as well as tslint has integration to the language services as well.

@jslegers
Copy link
Author

@kitsonk

Thanks!

@DanielRosenwasser DanielRosenwasser added the Question An issue which isn't directly actionable in code label Jun 22, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Aug 17, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Aug 17, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

4 participants