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
When using queryClient.setQueryData inside an expression body arrow function (without curly braces), the updater function's data parameter is incorrectly typed as unknown.
However, when used in a block body arrow function (with curly braces), the type is correctly inferred as expected.
Check the type inference on both mutation1 and mutation2 examples
Observe that in mutation1 (expression body), the data parameter is typed as unknown
Observe that in mutation2 (block body), the data parameter is correctly typed as { data: string } | undefined
Expected behavior
The updater function's data parameter should be correctly typed in both cases, regardless of whether the arrow function uses an expression body or block body syntax.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
MacOS
I don't think this issue is related to what platform I use.
Tanstack Query adapter
None
TanStack Query version
v5.74.3
TypeScript version
v5.8.3
Additional context
I am looking into it and once I find a solution, I'll submit a PR.