-
Hi all, I've been trying to better understand why I'm seeing a typescript error after migrating from react-query v3 to v4. Sorry if this has been answered before but would greatly appreciate any insights on this! :) IssueDoing something like this:
Returns a type error:
The ProblemIf the generics are not specified in Potential SolutionsThe recommended approach is to not use
Questions
Code Sandboxhttps://codesandbox.io/s/goofy-gates-84llxt?file=/src/index.tsx References
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
The problem is more tricky than it initially seems. In v5, we've removed the overloads, and none of your solutions (except solution1, because it doesn't use The all have the same type error:
My best guess is because we have one overload left in v5, which is One quick fix that makes all solutions work is to also omit initialData from the QueryOptions (playground here). Even the initial, non-working example works fine with that. I think it might be that we are missing another overload here that has an implementation for |
Beta Was this translation helpful? Give feedback.
I think I have a fix here, see this test:
query/packages/react-query/src/__tests__/useQuery.types.test.tsx
Lines 103 to 124 in 8aee98f