react-query: Update refetch return type to promise (#41394)

* Update react-query refetch return type

* Update refetch expected types

* Fix tests for updated refetch types
This commit is contained in:
Oliver Winter
2020-01-09 13:33:02 -08:00
committed by Armando Aguirre
parent 5cf30d420c
commit 776cbc2734
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ export interface QueryResult<TResult, TVariables> {
isFetching: boolean;
isCached: boolean;
failureCount: number;
refetch: (arg?: {variables?: TVariables, merge?: (...args: any[]) => any, disableThrow?: boolean}) => void;
refetch: (arg?: {variables?: TVariables, merge?: (...args: any[]) => any, disableThrow?: boolean}) => Promise<void>;
}
export interface QueryResultPaginated<TResult, TVariables> extends QueryResult<TResult[], TVariables> {
+2 -2
View File
@@ -8,7 +8,7 @@ const querySimple = useQuery('todos',
querySimple.data; // $ExpectType string | null
querySimple.error; // $ExpectType Error | null
querySimple.isLoading; // $ExpectType boolean
querySimple.refetch(); // $ExpectType void
querySimple.refetch(); // $ExpectType Promise<void>
queryPaginated.fetchMore; // $ExpectError
queryPaginated.canFetchMore; // $ExpectError
queryPaginated.isFetchingMore; // $ExpectError
@@ -19,7 +19,7 @@ const queryVariables = useQuery(['todos', {param}],
(variables) => Promise.resolve(variables.param === 'test'));
queryVariables.data; // $ExpectType boolean | null
queryVariables.refetch({variables: {param: 'foo'}}); // $ExpectType void
queryVariables.refetch({variables: {param: 'foo'}}); // $ExpectType Promise<void>
queryVariables.refetch({variables: {other: 'foo'}}); // $ExpectError
// Query with falsey query key