flow-to-typescript
flow-to-typescript copied to clipboard
Continued development / support
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 :smiley:
Hey, thanks @jthegedus! I do, but it's on my back burner. I started working on this, then realized two things:
- 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.
- 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.
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.
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.
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?
@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.
FYI: Seems there is another project with the similar functionality https://github.com/Kiikurage/babel-plugin-flow-to-typescript#readme