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

Continued development / support #1

Open
jthegedus opened this issue Mar 4, 2018 · 6 comments
Open

Continued development / support #1

jthegedus opened this issue Mar 4, 2018 · 6 comments

Comments

@jthegedus
Copy link

This tool looks to be extremely useful and I was wondering if you personally intend to work on this further? Although I know nothing about how it works, I would certainly be open to contributing supposing PRs would be merged etc. I see great use for this tool in bridging the Flow/TS world 😃

@bcherny
Copy link
Owner

bcherny commented Mar 4, 2018

Hey, thanks @jthegedus! I do, but it's on my back burner. I started working on this, then realized two things:

  1. The babel-types typings are really incomplete and inaccurate. I fixed this by codegen'ing TypeScript typings in babel-types itself, to guarantee that types are complete and accurate. This is now merged into babel, making the work for flow-to-ts significantly easier.
  2. A walker pattern isn't adequate for converting an AST from Flow -> TS, because once you convert a node, you also have to convert all of its descendants. A walker is great for terminal nodes, but doesn't work well elsewhere. So I began workin on the https://github.com/bcherny/flow-to-typescript/tree/recursive-descent branch, which walks the Flow AST nodes with a basic depth first traversal to convert them to TS.

The remaining work is for (2) in the branch I linked, to make sure all types of nodes are covered, and are mapped to their TS counterparts. Luckily TS's completeness checking for unions will warn us if we're missing anything.

Contributions are welcome, otherwise I'll get back to this sometime. Feel free to fork the recursive-descent branch if you like.

@evans
Copy link

evans commented Mar 19, 2018

This project is super exciting! I Check out recast. It's an AST parser and it may help you traverse while you do the Flow -> TS conversion.

@simonbuchan
Copy link

I suspect using babel traverse could be helpful, except that the declarations are out of date!

I've been looking into doing TS declarations for babel 7, ironically found this library while looking for options for reducing the burden of keeping them up to date, since the babel source code uses flow already.

@jack-guy
Copy link

I have some interest in chipping in but none of the branches I've checked out are compiling right now. What exactly is the state of repo's code?

@jbreckmckye
Copy link

@jack-guy It's still very much pre-alpha. It's not really 'useable' right now so much as 'developable'.

If you have a pressing need to convert some Flow code you might be best off writing your own one-off converter using this project as a (very helpful) example, and just implementing the bits you need.

@miso-belica
Copy link

FYI: Seems there is another project with the similar functionality https://github.com/Kiikurage/babel-plugin-flow-to-typescript#readme

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

No branches or pull requests

7 participants