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

Bug: incorrect Flow types for plural fragments #2545

Open
mrtnzlml opened this Issue Oct 10, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@mrtnzlml
Contributor

mrtnzlml commented Oct 10, 2018

Hello! I think I found an error in generated Flow types. Fragments like this:

fragment Ticket_passengers on Passenger @relay(plural: true) {
  id
  ...MyFragment
}

currently generate this Flow type:

export type Ticket_passengers = $ReadOnlyArray<{|
  +id: string,
  +$fragmentRefs: MyFragment$ref
  +$refType: Ticket_passengers$ref,
|}>;

However, most of our types are nullable. This is not problem for most of the cases because we can just import the type and prefix it with ?. But we cannot do it here because it should be:

export type Ticket_passengers = $ReadOnlyArray<?{|
  //                                           ^^

  +id: string,
  +$fragmentRefs: MyFragment$ref
  +$refType: Ticket_passengers$ref,
|}>;

I am afraid it is not possible to do it from outside when imported. It's unfortunate because parrent component defines this type:

+passengers: ?$ReadOnlyArray<?{|
  +$fragmentRefs: Ticket_passengers$ref
|}>

and as you can see these types are incompatible (inner object is correctly nullable here).

@josephsavona

This comment has been minimized.

Show comment
Hide comment
@josephsavona

josephsavona Oct 10, 2018

Contributor

I think you're right, containers don't filter nulls when vending plural fragment props so the type should be a readonly array of nullable items.

Contributor

josephsavona commented Oct 10, 2018

I think you're right, containers don't filter nulls when vending plural fragment props so the type should be a readonly array of nullable items.

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