Skip to content

Commit dfbda9d

Browse files
authored
refactor(types): revert narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void (#9202)" (#9251)
This reverts commit 982f6ca.
1 parent 2db48f4 commit dfbda9d

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

docs/framework/react/plugins/persistQueryClient.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,12 @@ ReactDOM.createRoot(rootElement).render(
214214

215215
- `persistOptions: PersistQueryClientOptions`
216216
- all [options](#options) you can pass to [persistQueryClient](#persistqueryclient) minus the QueryClient itself
217-
- `onSuccess?: () => Promise<void> | void`
217+
- `onSuccess?: () => Promise<unknown> | unknown`
218218
- optional
219219
- will be called when the initial restore is finished
220220
- can be used to [resumePausedMutations](../../../../reference/QueryClient.md#queryclientresumepausedmutations)
221221
- if a Promise is returned, it will be awaited; restoring is seen as ongoing until then
222-
- `onError?: () => Promise<void> | void`
222+
- `onError?: () => Promise<unknown> | unknown`
223223
- optional
224224
- will be called when an error is thrown during restoration
225225
- if a Promise is returned, it will be awaited

docs/framework/react/reference/useMutation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ mutate(variables, {
6868
- This function will fire before the mutation function is fired and is passed the same variables the mutation function would receive
6969
- Useful to perform optimistic updates to a resource in hopes that the mutation succeeds
7070
- 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.
71-
- `onSuccess: (data: TData, variables: TVariables, context: TContext) => Promise<void> | void`
71+
- `onSuccess: (data: TData, variables: TVariables, context: TContext) => Promise<unknown> | unknown`
7272
- Optional
7373
- This function will fire when the mutation is successful and will be passed the mutation's result.
7474
- If a promise is returned, it will be awaited and resolved before proceeding
75-
- `onError: (err: TError, variables: TVariables, context?: TContext) => Promise<void> | void`
75+
- `onError: (err: TError, variables: TVariables, context?: TContext) => Promise<unknown> | unknown`
7676
- Optional
7777
- This function will fire if the mutation encounters an error and will be passed the error.
7878
- If a promise is returned, it will be awaited and resolved before proceeding
79-
- `onSettled: (data: TData, error: TError, variables: TVariables, context?: TContext) => Promise<void> | void`
79+
- `onSettled: (data: TData, error: TError, variables: TVariables, context?: TContext) => Promise<unknown> | unknown`
8080
- Optional
8181
- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
8282
- If a promise is returned, it will be awaited and resolved before proceeding

docs/reference/MutationCache.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ Its available methods are:
2828

2929
**Options**
3030

31-
- `onError?: (error: unknown, variables: unknown, context: unknown, mutation: Mutation) => Promise<void> | void`
31+
- `onError?: (error: unknown, variables: unknown, context: unknown, mutation: Mutation) => Promise<unknown> | unknown`
3232
- Optional
3333
- This function will be called if some mutation encounters an error.
3434
- If you return a Promise from it, it will be awaited
35-
- `onSuccess?: (data: unknown, variables: unknown, context: unknown, mutation: Mutation) => Promise<void> | void`
35+
- `onSuccess?: (data: unknown, variables: unknown, context: unknown, mutation: Mutation) => Promise<unknown> | unknown`
3636
- Optional
3737
- This function will be called if some mutation is successful.
3838
- If you return a Promise from it, it will be awaited
39-
- `onSettled?: (data: unknown | undefined, error: unknown | null, variables: unknown, context: unknown, mutation: Mutation) => Promise<void> | void`
39+
- `onSettled?: (data: unknown | undefined, error: unknown | null, variables: unknown, context: unknown, mutation: Mutation) => Promise<unknown> | unknown`
4040
- Optional
4141
- This function will be called if some mutation is settled (either successful or errored).
4242
- If you return a Promise from it, it will be awaited
43-
- `onMutate?: (variables: unknown, mutation: Mutation) => Promise<void> | void`
43+
- `onMutate?: (variables: unknown, mutation: Mutation) => Promise<unknown> | unknown`
4444
- Optional
4545
- This function will be called before some mutation executes.
4646
- If you return a Promise from it, it will be awaited

packages/angular-query-persist-client/src/with-persist-query-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import type { PersistQueryClientFeature } from '@tanstack/angular-query-experime
2020

2121
type PersistQueryClientOptions = {
2222
persistOptions: Omit<PersistQueryClientOptionsCore, 'queryClient'>
23-
onSuccess?: () => Promise<void> | void
24-
onError?: () => Promise<void> | void
23+
onSuccess?: () => Promise<unknown> | unknown
24+
onError?: () => Promise<unknown> | unknown
2525
}
2626

2727
/**

packages/query-core/src/mutationCache.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@ interface MutationCacheConfig {
1616
variables: unknown,
1717
context: unknown,
1818
mutation: Mutation<unknown, unknown, unknown>,
19-
) => Promise<void> | void
19+
) => Promise<unknown> | unknown
2020
onSuccess?: (
2121
data: unknown,
2222
variables: unknown,
2323
context: unknown,
2424
mutation: Mutation<unknown, unknown, unknown>,
25-
) => Promise<void> | void
25+
) => Promise<unknown> | unknown
2626
onMutate?: (
2727
variables: unknown,
2828
mutation: Mutation<unknown, unknown, unknown>,
29-
) => Promise<void> | void
29+
) => Promise<unknown> | unknown
3030
onSettled?: (
3131
data: unknown | undefined,
3232
error: DefaultError | null,
3333
variables: unknown,
3434
context: unknown,
3535
mutation: Mutation<unknown, unknown, unknown>,
36-
) => Promise<void> | void
36+
) => Promise<unknown> | unknown
3737
}
3838

3939
interface NotifyEventMutationAdded extends NotifyEvent {

packages/query-core/src/query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export interface FetchContext<
6666
TData,
6767
TQueryKey extends QueryKey = QueryKey,
6868
> {
69-
fetchFn: () => Promise<unknown> | unknown
69+
fetchFn: () => unknown | Promise<unknown>
7070
fetchOptions?: FetchOptions
7171
signal: AbortSignal
7272
options: QueryOptions<TQueryFnData, TError, TData, any>

packages/query-core/src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,18 +1106,18 @@ export interface MutationOptions<
11061106
data: TData,
11071107
variables: TVariables,
11081108
context: TContext,
1109-
) => Promise<void> | void
1109+
) => Promise<unknown> | unknown
11101110
onError?: (
11111111
error: TError,
11121112
variables: TVariables,
11131113
context: TContext | undefined,
1114-
) => Promise<void> | void
1114+
) => Promise<unknown> | unknown
11151115
onSettled?: (
11161116
data: TData | undefined,
11171117
error: TError | null,
11181118
variables: TVariables,
11191119
context: TContext | undefined,
1120-
) => Promise<void> | void
1120+
) => Promise<unknown> | unknown
11211121
retry?: RetryValue<TError>
11221122
retryDelay?: RetryDelayValue<TError>
11231123
networkMode?: NetworkMode

packages/react-query-persist-client/src/PersistQueryClientProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import type { OmitKeyof, QueryClientProviderProps } from '@tanstack/react-query'
1111

1212
export type PersistQueryClientProviderProps = QueryClientProviderProps & {
1313
persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>
14-
onSuccess?: () => Promise<void> | void
15-
onError?: () => Promise<void> | void
14+
onSuccess?: () => Promise<unknown> | unknown
15+
onError?: () => Promise<unknown> | unknown
1616
}
1717

1818
export const PersistQueryClientProvider = ({

0 commit comments

Comments
 (0)