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

Support TSESTree input and TypeScript output #707

Open
bjornharrtell opened this issue May 9, 2024 · 4 comments
Open

Support TSESTree input and TypeScript output #707

bjornharrtell opened this issue May 9, 2024 · 4 comments
Labels

Comments

@bjornharrtell
Copy link
Contributor

Motivation

My own motivation is that I have a translation from a typed language (Java) to ESTree and generate JavaScript from that with astring, but would like to preseve some of the type information and target TypeScript instead.

Apparently eslint has made exensions to ESTree called TSESTree but AFAICT they only use it to transform TypeScript into AST not the other way round.

Expected behavior

A flag to output TypeScript.

@davidbonnet
Copy link
Owner

Hi @bjornharrtell, TypeScript support would indeed be interesting. Could you provide more insights regarding the TSESTree spec?

@bjornharrtell
Copy link
Contributor Author

I'm unable to find a formal spec extension to estree. The basis of the extensions seems to live at https://github.com/typescript-eslint/typescript-eslint/blob/8f08ee54d1389666b3f582853a8b6809d34d70f8/packages/ast-spec/src/ast-node-types.ts#L94-L171, which enumerates all the added node types.

At https://typescript-eslint.io/play you can supply TypeScript code and generate TSESTree, but not the other way round. I asked about a year ago and it was clarified that implementation to do TSESTree to TypeScript doesn't exist (yet), see typescript-eslint/typescript-eslint#7228.

@bjornharrtell
Copy link
Contributor Author

I see now that the code is very spec like fx. https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/ast-spec/src/special/TSTypeParameter/spec.ts

@wooorm
Copy link

wooorm commented Jun 21, 2024

see also https://github.com/TyrealHu/acorn-typescript btw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants