Skip to content

Commit b95b865

Browse files
fix(MutationOptions): improve the type of onMutate (#2494)
set the return type of onMutate as Promise<TContext | undefined> instead of Promise<TContext> | Promise<undefined> to make it work with async functions
1 parent 51a226e commit b95b865

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/core/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ export interface MutationOptions<
481481
variables?: TVariables
482482
onMutate?: (
483483
variables: TVariables
484-
) => Promise<TContext> | Promise<undefined> | TContext | undefined
484+
) => Promise<TContext | undefined> | TContext | undefined
485485
onSuccess?: (
486486
data: TData,
487487
variables: TVariables,

src/react/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export interface UseMutationOptions<
7777
mutationKey?: MutationKey
7878
onMutate?: (
7979
variables: TVariables
80-
) => Promise<TContext> | Promise<undefined> | TContext | undefined
80+
) => Promise<TContext | undefined> | TContext | undefined
8181
onSuccess?: (
8282
data: TData,
8383
variables: TVariables,

0 commit comments

Comments
 (0)