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

Intersection types #14

Open rrdelaney opened 7 years ago

rrdelaney commented 7 years ago

The type A & B will combine record types in Flow, we should also support it

bbqbaron commented 7 years ago

I'd like to start on this. Not knowing as much as I should about Ocaml, though, can I ask for a high-level approach description? I don't see a way for Ocaml to declare an intersection record type using something like &. I could certainly hand-construct an intersection of any two given types, but not declare the type relationship between some 'a and 'b in, say:

external mergeThings: 'a => 'b => ??? = "" [@@bs.module "stuff"];

How would this be accomplished?

rrdelaney commented 7 years ago

I don't really know either 😕 Maybe something like a type spread?

If you're looking for something pretty do-able #15 might be a good option 🙂