From 776cbc2734888de45f54da97232caebe3451e1a1 Mon Sep 17 00:00:00 2001 From: Oliver Winter Date: Thu, 9 Jan 2020 22:33:02 +0100 Subject: [PATCH] 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 --- types/react-query/index.d.ts | 2 +- types/react-query/react-query-tests.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/react-query/index.d.ts b/types/react-query/index.d.ts index e8c79b24e7..496b3f5fa7 100644 --- a/types/react-query/index.d.ts +++ b/types/react-query/index.d.ts @@ -52,7 +52,7 @@ export interface QueryResult { 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; } export interface QueryResultPaginated extends QueryResult { diff --git a/types/react-query/react-query-tests.ts b/types/react-query/react-query-tests.ts index 5ed0670d3d..55770da83b 100644 --- a/types/react-query/react-query-tests.ts +++ b/types/react-query/react-query-tests.ts @@ -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 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 queryVariables.refetch({variables: {other: 'foo'}}); // $ExpectError // Query with falsey query key