@@ -25,16 +25,13 @@ const useStaticFragmentNodeWarning = require('./useStaticFragmentNodeWarning');
25
25
const { useDebugValue} = require ( 'react' ) ;
26
26
const { getFragment} = require ( 'relay-runtime' ) ;
27
27
28
- type RefetchVariables < TVariables , TKey > =
29
- // NOTE: This $Call ensures that the type of the returned variables is either:
28
+ type RefetchVariables < TVariables , TKey : ? { + $fragmentSpreads : mixed , ... } > =
29
+ // NOTE: This type ensures that the type of the returned variables is either:
30
30
// - nullable if the provided ref type is nullable
31
31
// - non-nullable if the provided ref type is non-nullable
32
- // prettier-ignore
33
- $Call <
34
- & ( < TFragmentType > ( { + $fragmentSpreads : TFragmentType , ... } ) => Partial < TVariables > )
35
- & ( < TFragmentType > (?{ + $fragmentSpreads : TFragmentType , ... } ) => TVariables ) ,
36
- TKey ,
37
- > ;
32
+ [ + key : TKey ] extends [ + key : { + $fragmentSpreads : mixed , ...} ]
33
+ ? Partial < TVariables >
34
+ : TVariables ;
38
35
39
36
type RefetchFnBase < TVars , TOptions > = (
40
37
vars : TVars ,
@@ -46,16 +43,15 @@ export type RefetchFn<TVariables, TKey, TOptions = Options> = RefetchFnBase<
46
43
TOptions ,
47
44
> ;
48
45
49
- export type ReturnType < TVariables , TData , TKey > = [
50
- // NOTE: This $Call ensures that the type of the returned data is either:
46
+ export type ReturnType <
47
+ TVariables ,
48
+ TData ,
49
+ TKey : ?{ + $fragmentSpreads : mixed , ...} ,
50
+ > = [
51
+ // NOTE: This type ensures that the type of the returned data is either:
51
52
// - nullable if the provided ref type is nullable
52
53
// - non-nullable if the provided ref type is non-nullable
53
- // prettier-ignore
54
- $Call<
55
- & ( < TFragmentType > ( { + $fragmentSpreads : TFragmentType , ... } ) => TData )
56
- & ( < TFragmentType > (?{ + $fragmentSpreads : TFragmentType , ... } ) => ?TData ) ,
57
- TKey ,
58
- > ,
54
+ [ + key : TKey ] extends [ + key : { + $fragmentSpreads : mixed , ...} ] ? TData : ?TData ,
59
55
RefetchFn < TVariables , TKey > ,
60
56
] ;
61
57
@@ -115,6 +111,7 @@ function useRefetchableFragment<
115
111
) : ReturnType < TVariables , TData, TKey > {
116
112
const impl = HooksImplementation . get ( ) ;
117
113
if ( impl ) {
114
+ // $FlowExpectedError[incompatible-return] Flow cannot prove that two conditional type satisfy each other
118
115
return impl . useRefetchableFragment < TFragmentType , TVariables , TData , TKey > (
119
116
fragmentInput ,
120
117
parentFragmentRef ,
0 commit comments