Describe the bug#
The type of context in the useMutation callbacks depends on the sorting of the options object.
Your minimal, reproducible example#
https://codesandbox.io/p/devbox/usemutationcontext-qsnk89
Steps to reproduce#
- Open minimal reproduction
- Open file
src/index.tsx or run tsc --noemit
- Type of
context in callbacks depends options object sorting
- first
useMutation works as intended, second useMutation has type errors
Expected behavior#
The type of context in useMutation 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
Should you define type for it first? Like this
Then the type error will disappear