mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
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:
committed by
Armando Aguirre
parent
5cf30d420c
commit
776cbc2734
Vendored
+1
-1
@@ -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> {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user