react-native-macos/flow
Sam Goldman ab1a42762c Make RelayObservable Source return type disjoint
Summary:
In Flow v0.99 we are changing function type annotations to be strict about their
static properties. This causes a small issue with the union of a Subcription and
`() => mixed` function type, where the latter is now understood to possibly have
an `unsubscribe` property with a mixed type.

This causes the following refinement check, which appears lower in this file, to
cause an error in the next version of Flow:

```
if (cleanup) {
  if (cleanup.unsubscribe) {
    cleanup.unsubscribe(); // <-- error here
  }
  // ...
}
```

In Flow v0.99, because `() => mixed` statics are now checked, Flow sees that
`cleanup.unsubscribe` might be `mixed`, which passes the conditional but could
cause an exception when called.

I also needed to change JestMockFn to have exact statics, because tests
sometimes use a value with that type in place of the cleanup function. That runs
into the `{} <: {+p?: void}` rule, which is an error. `{||} <: {+p?:void}` is
not an error.

Reviewed By: josephsavona

Differential Revision: D15522655

fbshipit-source-id: 2ae3c9016e2b07abaac79827082d2f8743623eb5
2019-05-28 12:13:49 -07:00
..
Map.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
Position.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
Promise.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
Set.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
Stringish.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
console.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
jest.js Make RelayObservable Source return type disjoint 2019-05-28 12:13:49 -07:00