From 1ef2753d2ce806ea9b34e150f272eb049869e4be Mon Sep 17 00:00:00 2001 From: Simone Cervini Date: Wed, 14 Aug 2024 23:23:57 +0200 Subject: [PATCH] init --- packages/query-core/src/queryClient.ts | 21 +++++++++++++++++---- packages/vue-query/src/queryClient.ts | 21 +++++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/packages/query-core/src/queryClient.ts b/packages/query-core/src/queryClient.ts index 49855e668b..17f1581e35 100644 --- a/packages/query-core/src/queryClient.ts +++ b/packages/query-core/src/queryClient.ts @@ -429,10 +429,18 @@ export class QueryClient { this.#defaultOptions = options } - setQueryDefaults( + setQueryDefaults< + TQueryFnData = unknown, + TError = DefaultError, + TData = TQueryFnData, + TQueryData = TQueryFnData, + >( queryKey: QueryKey, options: Partial< - OmitKeyof, 'queryKey'> + OmitKeyof< + QueryObserverOptions, + 'queryKey' + > >, ): void { this.#queryDefaults.set(hashKey(queryKey), { @@ -459,10 +467,15 @@ export class QueryClient { return result } - setMutationDefaults( + setMutationDefaults< + TData = unknown, + TError = DefaultError, + TVariables = void, + TContext = unknown, + >( mutationKey: MutationKey, options: OmitKeyof< - MutationObserverOptions, + MutationObserverOptions, 'mutationKey' >, ): void { diff --git a/packages/vue-query/src/queryClient.ts b/packages/vue-query/src/queryClient.ts index 281eca714a..9909b51a06 100644 --- a/packages/vue-query/src/queryClient.ts +++ b/packages/vue-query/src/queryClient.ts @@ -3,6 +3,7 @@ import { QueryClient as QC } from '@tanstack/query-core' import { cloneDeepUnref } from './utils' import { QueryCache } from './queryCache' import { MutationCache } from './mutationCache' +import type { UseQueryOptions } from './useQuery' import type { Ref } from 'vue-demi' import type { MaybeRefDeep, NoUnknown } from './types' import type { @@ -377,10 +378,15 @@ export class QueryClient extends QC { super.setDefaultOptions(cloneDeepUnref(options)) } - setQueryDefaults( + setQueryDefaults< + TQueryFnData = unknown, + TError = DefaultError, + TData = TQueryFnData, + TQueryData = TQueryFnData, + >( queryKey: MaybeRefDeep, options: MaybeRefDeep< - OmitKeyof, 'queryKey'> + Omit, 'queryKey'> >, ): void { super.setQueryDefaults(cloneDeepUnref(queryKey), cloneDeepUnref(options)) @@ -392,9 +398,16 @@ export class QueryClient extends QC { return super.getQueryDefaults(cloneDeepUnref(queryKey)) } - setMutationDefaults( + setMutationDefaults< + TData = unknown, + TError = DefaultError, + TVariables = void, + TContext = unknown, + >( mutationKey: MaybeRefDeep, - options: MaybeRefDeep>, + options: MaybeRefDeep< + MutationObserverOptions + >, ): void { super.setMutationDefaults( cloneDeepUnref(mutationKey),