rrdelaney / ReasonablyTyped

:diamond_shape_with_a_dot_inside: Converts Flow and TypeScript definitions to Reason interfaces

Home Page:https://rrdelaney.github.io/ReasonablyTyped/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Render Flow object types as open

bbqbaron opened this issue · comments

While researching #19, I wonder if there's an upstream change we need to make. We render Flow object types as closed Reason objects, but I think they're supposed to be open, aren't they?

Right now, test object-type:

declare type subscribeOptions = {
  start: number,
  stop: number
}

becomes

type subscribeOptions = Js.t {. start : float, stop : float};

However, Flow permits extra fields in object types that aren't exact. For example, function foo(x: SubscribeOptions) should accept objects with more than just start and stop on them.

Should we produce instead Js.t {.. start: float, stop: float } unless the type is declared with {| |}?

This seems correct to me! We should definitely try to output as close to Flow bindings as possible, and match the default of open types!

Created #27 for supporting closed object types after we move to outputting open ones

Closed by #29. Thanks @bbqbaron!