From 1fbabda58a5b96b50ec012ecc81819228c9c71e4 Mon Sep 17 00:00:00 2001 From: Benedikt Date: Fri, 10 Jul 2020 19:58:55 +0200 Subject: [PATCH 1/2] fix: include undefined in IniniteQueryResult data type --- types/index.d.ts | 2 +- types/test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 5d7798b1bf..8902410fe5 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -378,7 +378,7 @@ export type PaginatedQueryResult = export interface InfiniteQueryResult extends QueryResultBase { - data: TResult[] + data: TResult[] | undefined isFetchingMore: false | 'previous' | 'next' canFetchMore: boolean | undefined fetchMore: ( diff --git a/types/test.ts b/types/test.ts index 630911b08b..92c93164bb 100644 --- a/types/test.ts +++ b/types/test.ts @@ -339,7 +339,7 @@ function simpleInfiniteQuery(condition: boolean) { // getFetchMore: (last, all) => 'string', // }); - infiniteQuery.data // $ExpectType number[][] + infiniteQuery.data // $ExpectType number[][] | undefined infiniteQuery.fetchMore() // $ExpectType Promise | undefined infiniteQuery.fetchMore('next') // $ExpectType Promise | undefined infiniteQuery.fetchMore('next', { previous: true }) // $ExpectType Promise | undefined From 35cf92dde17da952ea35472dca227cb5d1a44104 Mon Sep 17 00:00:00 2001 From: Benedikt Date: Fri, 10 Jul 2020 21:21:59 +0200 Subject: [PATCH 2/2] fix: dtslint --- types/test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/test.ts b/types/test.ts index 92c93164bb..f9184dcdd5 100644 --- a/types/test.ts +++ b/types/test.ts @@ -352,14 +352,14 @@ function infiniteQueryWithObjectSyntax() { config: { getFetchMore: (last: { next: number }) => last.next, // annotation on this type is required to infer the type }, - }).data // $ExpectType { next: number; }[] + }).data // $ExpectType { next: number; }[] | undefined useInfiniteQuery({ queryKey: ['key', 1], queryFn: async (key, id, next = 0) => ({ next: next + 1 }), config: { getFetchMore: (last: { next: number }) => last.next, // annotation on this type is required to infer the type }, - }).data // $ExpectType { next: number; }[] + }).data // $ExpectType { next: number; }[] | undefined useInfiniteQuery({ queryKey: 'key', queryFn: async ( @@ -369,7 +369,7 @@ function infiniteQueryWithObjectSyntax() { config: { getFetchMore: (last: { next: number }) => last.next, // annotation on this type is required to infer the type }, - }).data // $ExpectType { next: number; }[] + }).data // $ExpectType { next: number; }[] | undefined useInfiniteQuery({ queryKey: 'key', queryFn: async ( @@ -379,15 +379,15 @@ function infiniteQueryWithObjectSyntax() { config: { getFetchMore: (last: { next: number }) => last.next, // annotation on this type is required to infer the type }, - }).data // $ExpectType { next: number; }[] + }).data // $ExpectType { next: number; }[] | undefined useInfiniteQuery<{ next: number }, string, undefined>({ queryKey: 'key', - }).data // $ExpectType { next: number; }[] + }).data // $ExpectType { next: number; }[] | undefined useInfiniteQuery<{ next: number }, [string], undefined>({ queryKey: ['key'], - }).data // $ExpectType { next: number; }[] + }).data // $ExpectType { next: number; }[] | undefined } function log(...args: any[]) {}