diff --git a/docs/framework/react/plugins/persistQueryClient.md b/docs/framework/react/plugins/persistQueryClient.md index 77e9aa5b13..4cf6be9288 100644 --- a/docs/framework/react/plugins/persistQueryClient.md +++ b/docs/framework/react/plugins/persistQueryClient.md @@ -214,12 +214,12 @@ ReactDOM.createRoot(rootElement).render( - `persistOptions: PersistQueryClientOptions` - all [options](#options) you can pass to [persistQueryClient](#persistqueryclient) minus the QueryClient itself -- `onSuccess?: () => Promise | unknown` +- `onSuccess?: () => Promise | void` - optional - will be called when the initial restore is finished - can be used to [resumePausedMutations](../../../../reference/QueryClient.md#queryclientresumepausedmutations) - if a Promise is returned, it will be awaited; restoring is seen as ongoing until then -- `onError?: () => Promise | unknown` +- `onError?: () => Promise | void` - optional - will be called when an error is thrown during restoration - if a Promise is returned, it will be awaited diff --git a/docs/framework/react/reference/useMutation.md b/docs/framework/react/reference/useMutation.md index 9147c072ef..80545c517e 100644 --- a/docs/framework/react/reference/useMutation.md +++ b/docs/framework/react/reference/useMutation.md @@ -68,15 +68,15 @@ mutate(variables, { - This function will fire before the mutation function is fired and is passed the same variables the mutation function would receive - Useful to perform optimistic updates to a resource in hopes that the mutation succeeds - The value returned from this function will be passed to both the `onError` and `onSettled` functions in the event of a mutation failure and can be useful for rolling back optimistic updates. -- `onSuccess: (data: TData, variables: TVariables, context: TContext) => Promise | unknown` +- `onSuccess: (data: TData, variables: TVariables, context: TContext) => Promise | void` - Optional - This function will fire when the mutation is successful and will be passed the mutation's result. - If a promise is returned, it will be awaited and resolved before proceeding -- `onError: (err: TError, variables: TVariables, context?: TContext) => Promise | unknown` +- `onError: (err: TError, variables: TVariables, context?: TContext) => Promise | void` - Optional - This function will fire if the mutation encounters an error and will be passed the error. - If a promise is returned, it will be awaited and resolved before proceeding -- `onSettled: (data: TData, error: TError, variables: TVariables, context?: TContext) => Promise | unknown` +- `onSettled: (data: TData, error: TError, variables: TVariables, context?: TContext) => Promise | void` - Optional - This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error - If a promise is returned, it will be awaited and resolved before proceeding diff --git a/docs/reference/MutationCache.md b/docs/reference/MutationCache.md index 9e8ef2e61a..63c9a4133f 100644 --- a/docs/reference/MutationCache.md +++ b/docs/reference/MutationCache.md @@ -28,19 +28,19 @@ Its available methods are: **Options** -- `onError?: (error: unknown, variables: unknown, context: unknown, mutation: Mutation) => Promise | unknown` +- `onError?: (error: unknown, variables: unknown, context: unknown, mutation: Mutation) => Promise | void` - Optional - This function will be called if some mutation encounters an error. - If you return a Promise from it, it will be awaited -- `onSuccess?: (data: unknown, variables: unknown, context: unknown, mutation: Mutation) => Promise | unknown` +- `onSuccess?: (data: unknown, variables: unknown, context: unknown, mutation: Mutation) => Promise | void` - Optional - This function will be called if some mutation is successful. - If you return a Promise from it, it will be awaited -- `onSettled?: (data: unknown | undefined, error: unknown | null, variables: unknown, context: unknown, mutation: Mutation) => Promise | unknown` +- `onSettled?: (data: unknown | undefined, error: unknown | null, variables: unknown, context: unknown, mutation: Mutation) => Promise | void` - Optional - This function will be called if some mutation is settled (either successful or errored). - If you return a Promise from it, it will be awaited -- `onMutate?: (variables: unknown, mutation: Mutation) => Promise | unknown` +- `onMutate?: (variables: unknown, mutation: Mutation) => Promise | void` - Optional - This function will be called before some mutation executes. - If you return a Promise from it, it will be awaited diff --git a/packages/angular-query-persist-client/src/with-persist-query-client.ts b/packages/angular-query-persist-client/src/with-persist-query-client.ts index ceeeed01cd..d6ad609c8f 100644 --- a/packages/angular-query-persist-client/src/with-persist-query-client.ts +++ b/packages/angular-query-persist-client/src/with-persist-query-client.ts @@ -20,8 +20,8 @@ import type { PersistQueryClientFeature } from '@tanstack/angular-query-experime type PersistQueryClientOptions = { persistOptions: Omit - onSuccess?: () => Promise | unknown - onError?: () => Promise | unknown + onSuccess?: () => Promise | void + onError?: () => Promise | void } /** diff --git a/packages/query-core/src/mutationCache.ts b/packages/query-core/src/mutationCache.ts index 6ab95fbfed..3739388a64 100644 --- a/packages/query-core/src/mutationCache.ts +++ b/packages/query-core/src/mutationCache.ts @@ -16,24 +16,24 @@ interface MutationCacheConfig { variables: unknown, context: unknown, mutation: Mutation, - ) => Promise | unknown + ) => Promise | void onSuccess?: ( data: unknown, variables: unknown, context: unknown, mutation: Mutation, - ) => Promise | unknown + ) => Promise | void onMutate?: ( variables: unknown, mutation: Mutation, - ) => Promise | unknown + ) => Promise | void onSettled?: ( data: unknown | undefined, error: DefaultError | null, variables: unknown, context: unknown, mutation: Mutation, - ) => Promise | unknown + ) => Promise | void } interface NotifyEventMutationAdded extends NotifyEvent { diff --git a/packages/query-core/src/query.ts b/packages/query-core/src/query.ts index e6ad4ca4ee..481480f656 100644 --- a/packages/query-core/src/query.ts +++ b/packages/query-core/src/query.ts @@ -65,7 +65,7 @@ export interface FetchContext< TData, TQueryKey extends QueryKey = QueryKey, > { - fetchFn: () => unknown | Promise + fetchFn: () => Promise | unknown fetchOptions?: FetchOptions signal: AbortSignal options: QueryOptions diff --git a/packages/query-core/src/types.ts b/packages/query-core/src/types.ts index 735b8ea263..84f632c171 100644 --- a/packages/query-core/src/types.ts +++ b/packages/query-core/src/types.ts @@ -1105,18 +1105,18 @@ export interface MutationOptions< data: TData, variables: TVariables, context: TContext, - ) => Promise | unknown + ) => Promise | void onError?: ( error: TError, variables: TVariables, context: TContext | undefined, - ) => Promise | unknown + ) => Promise | void onSettled?: ( data: TData | undefined, error: TError | null, variables: TVariables, context: TContext | undefined, - ) => Promise | unknown + ) => Promise | void retry?: RetryValue retryDelay?: RetryDelayValue networkMode?: NetworkMode diff --git a/packages/react-query-persist-client/src/PersistQueryClientProvider.tsx b/packages/react-query-persist-client/src/PersistQueryClientProvider.tsx index b12dba8810..808a2e7a57 100644 --- a/packages/react-query-persist-client/src/PersistQueryClientProvider.tsx +++ b/packages/react-query-persist-client/src/PersistQueryClientProvider.tsx @@ -11,8 +11,8 @@ import type { OmitKeyof, QueryClientProviderProps } from '@tanstack/react-query' export type PersistQueryClientProviderProps = QueryClientProviderProps & { persistOptions: OmitKeyof - onSuccess?: () => Promise | unknown - onError?: () => Promise | unknown + onSuccess?: () => Promise | void + onError?: () => Promise | void } export const PersistQueryClientProvider = ({