rrdelaney / ReasonablyTyped

:diamond_shape_with_a_dot_inside: Converts Flow and TypeScript definitions to Reason interfaces
https://rrdelaney.github.io/ReasonablyTyped/
MIT License
518 stars 24 forks source link

Any Project to go from Reason to Flow types? #57

Closed nmn closed 6 years ago

nmn commented 6 years ago

A Converter from Reason files to Flow type definition files?

This is probably out of scope for the project but I just wanted to bring it up in case there's any work already done in the area. If we run ocamlc -dtypedtree on an .mli file, it gives all the data that is generally needed to generate a flow type definition file. There are a few clever Flow tricks to make it not lossy, by using Tuple types and opaque types, but it should definitely be possible.

This project I feel like would be very useful if we want to move to a world where we can write libraries in Reason/Ocaml and generate the Javascript and also the types in Flow/Typescript.

Thoughts?

rrdelaney commented 6 years ago

I think the Reason team is already working on something like this 😄 That said, if you wanted to work on it in the context of this project you would have to:

  1. Parse Reason/OCaml source and get type info
  2. Translate that type info to a BsTypeAst
  3. Print that using the existing Flow printer

This is also how we've accidentally made a TS -> Flow translator lol

bwestergard commented 6 years ago

@nmn I agree that this would be amazing. Bucklescript, which does the code generation for Reason, would need to support it. See this thread.

rrdelaney commented 6 years ago

I think the Reason team is now actively working on this.

bwestergard commented 6 years ago

@rrdelaney Yes, it appears so. Do you know where that development is taking place? @jordwalke made it sound as though code had already been written here.