From ee338d43627c0f57a248990e05d71513e49e8e45 Mon Sep 17 00:00:00 2001 From: liaoliao666 <1076988944@qq.com> Date: Mon, 18 Sep 2023 04:21:44 +0800 Subject: [PATCH] feat: add inferError & optimize removeQueries type --- src/vanilla/queryClient.ts | 8 +++----- src/vanilla/types.ts | 7 +++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/vanilla/queryClient.ts b/src/vanilla/queryClient.ts index 0870f03..8fe94ce 100644 --- a/src/vanilla/queryClient.ts +++ b/src/vanilla/queryClient.ts @@ -62,8 +62,6 @@ export interface InvalidateQueryFilters< refetchType?: QueryInfoTypeFilter | 'none' } -export type GetPages = - TQueryData extends InfiniteData ? { pages?: number } : object export type FetchQueryOptions< TFetcherData = unknown, @@ -271,7 +269,7 @@ export const createQueryClient = (config: QueryClientConfig = {}) => { TError = Error, TQueryData = TFetcherData >( - filters: QueryInfoFilters + filters?: QueryInfoFilters ): [ QueryInfo, TQueryData | undefined @@ -305,7 +303,7 @@ export const createQueryClient = (config: QueryClientConfig = {}) => { TError = Error, TQueryData = TFetcherData >( - filters: QueryInfoFilters + filters?: QueryInfoFilters ) => { queryCache .findAll(filters) @@ -376,7 +374,7 @@ export const createQueryClient = (config: QueryClientConfig = {}) => { TError = Error, TQueryData = TFetcherData >( - filters: QueryInfoFilters = {}, + filters?: QueryInfoFilters , cancelOptions: CancelOptions = {} ): Promise => { const defaultedCancelOptions = { revert: true, ...cancelOptions } diff --git a/src/vanilla/types.ts b/src/vanilla/types.ts index 79eda6c..52778c2 100644 --- a/src/vanilla/types.ts +++ b/src/vanilla/types.ts @@ -19,3 +19,10 @@ export type inferData = T extends PrimitiveQuery ? TData : never + export type inferError = T extends PrimitiveQuery + ? TError + : T extends Mutation + ? TError + : never + +