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
This commit is contained in:
Родитель
77a6617a39
Коммит
ab1a42762c
|
@ -11,7 +11,7 @@
|
|||
|
||||
/* eslint-disable lint/no-unclear-flowtypes */
|
||||
|
||||
type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
|
||||
type JestMockFn<TArguments: $ReadOnlyArray<mixed>, TReturn> = {|
|
||||
(...args: TArguments): TReturn,
|
||||
/**
|
||||
* An object for introspecting mock calls
|
||||
|
@ -105,7 +105,7 @@ type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
|
|||
* Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value))
|
||||
*/
|
||||
mockRejectedValueOnce(value: TReturn): JestMockFn<TArguments, Promise<any>>,
|
||||
};
|
||||
|};
|
||||
|
||||
type JestAsymmetricEqualityType = {
|
||||
/**
|
||||
|
@ -794,7 +794,7 @@ type JestObjectType = {
|
|||
* Returns a new, unused mock function. Optionally takes a mock
|
||||
* implementation.
|
||||
*/
|
||||
fn<TArguments: $ReadOnlyArray<*>, TReturn>(
|
||||
fn<TArguments: $ReadOnlyArray<mixed>, TReturn>(
|
||||
implementation?: (...args: TArguments) => TReturn,
|
||||
): JestMockFn<TArguments, TReturn>,
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче