Skip to content

Add a way to get a typed AST #16692

Closed
Closed

Description

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?

Activity

  1. kitsonk commented on Jun 22, 2017

    @kitsonk
    Contributor

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

  2. jslegers commented on Jun 22, 2017

    @jslegers
    Author

    Kitson Kelly (@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...

  3. kitsonk commented on Jun 22, 2017

    @kitsonk
    Contributor

    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.

  4. jslegers commented on Jun 22, 2017

    @jslegers
    Author
  5. mhegazy commented on Aug 17, 2017

    @mhegazy
    Contributor

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

  6. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions