facebook/flow

Incorrect error when assigning value through generic

danny-does-stuff opened this issue · 1 comments

Flow version: 0.187.1

Expected behavior

If a value can be assigned to a standard type, those same types should also be assignable when using generics.

Actual behavior

When assigning between generics, flow gives an error.

  • Link to Try-Flow or Github repo: clicky

This is expected, because you declare T as invariant. Check https://flow.org/en/docs/lang/variance/ for more detail.

If you do type Generic<+T> = T, then it will work.