Skip to content

Commit 3714a6b

Browse files
committed
fix(mutationObserver): updateResult should declare a type then cast
1 parent 454875f commit 3714a6b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/core/mutationObserver.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { QueryClient } from './queryClient'
44
import { Subscribable } from './subscribable'
55
import type {
66
MutateOptions,
7+
MutationObserverBaseResult,
78
MutationObserverResult,
89
MutationObserverOptions,
910
} from './types'
@@ -129,15 +130,27 @@ export class MutationObserver<
129130
? this.currentMutation.state
130131
: getDefaultState<TData, TError, TVariables, TContext>()
131132

132-
this.currentResult = {
133+
const result: MutationObserverBaseResult<
134+
TData,
135+
TError,
136+
TVariables,
137+
TContext
138+
> = {
133139
...state,
134140
isLoading: state.status === 'loading',
135141
isSuccess: state.status === 'success',
136142
isError: state.status === 'error',
137143
isIdle: state.status === 'idle',
138144
mutate: this.mutate,
139145
reset: this.reset,
140-
} as MutationObserverResult<TData, TError, TVariables, TContext>
146+
}
147+
148+
this.currentResult = result as MutationObserverResult<
149+
TData,
150+
TError,
151+
TVariables,
152+
TContext
153+
>
141154
}
142155

143156
private notify(options: NotifyOptions) {

0 commit comments

Comments
 (0)