Open 7schmiede opened 1 month ago
Yeah this is a really frustrating issue. I either have to choose between just injecting the query client at the top level, or manually typing all parameters in the callback functions
Same here. Figured out, specifying the queryClient type does the trick for the moment. At least better than every method arguments.
injectMutation((client: QueryClient) => ({
}));
One could fix this by wrapping TData
with NoInfer<TData>
in the MutationOptions
type of the core package at https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1005, but that would be a breaking change for all adapters.
Describe the bug
When the
queryClient
is passed in theinjectMutation
method, the return type ofmutationFn
is lost in theonSuccess
method.Your minimal, reproducible example
https://stackblitz.com/edit/stackblitz-starters-3zsk2e?file=test.ts
Steps to reproduce
Expected behavior
Even if the
queryClient
is passed, the return type of themutationFn
should remain in theonSuccess
method.How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Tanstack Query adapter
angular-query
TanStack Query version
v5.55.4
TypeScript version
No response
Additional context
No response