You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In an object, type consumers must come after type producers. onMutate produces the type, onError and onSettled consume them. This is a known typescript limitation:
We do have an eslint rule for infinite-query-property-order. @schiller-manuel do you think it would be possible to extend this to a more general rule that also covers this use-case?
Describe the bug
The type of
context
in theuseMutation
callbacks depends on the sorting of the options object.Your minimal, reproducible example
https://codesandbox.io/p/devbox/usemutationcontext-qsnk89
Steps to reproduce
src/index.tsx
or runtsc --noemit
context
in callbacks depends options object sortinguseMutation
works as intended, seconduseMutation
has type errorsExpected behavior
The type of
context
inuseMutation
callbacks should always be the same and not depend on the options object sorting.How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Seems to be a types only bug. Has no effect on runtime values.
Tanstack Query adapter
react-query
TanStack Query version
5.72.2
TypeScript version
5.8.2
Additional context
No response
The text was updated successfully, but these errors were encountered: