-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useQueries
+ skipToken
looses .data
type inference
#7035
Comments
@Jaaneek can you take a look here? I'm afraid I'm no expert with the |
Looking into it! |
@vjee quick fix is to add "as const" after queries array. queries: [
{ queryKey: ["withSkipToken"], queryFn: true ? () => 1 : skipToken },
] as const For some reason typescript doesnt make the array "readonly" by default when passing skipToken @TkDodo I'm looking for a solution that wouldn't require the "as const" |
Thanks for the quick fix. Great feature btw! Well done 👏 |
I found a fix, pull request incoming |
Seems like some other tests are failing once thix is fixed. Can't find a good solution at this moment. Feel free to contribute anyone! temporary fix is add
|
I've worked on the issue in question. Please take a look. |
Describe the bug
When using
useQueries
withskipToken
,queryResult.data
is inferred asunknown
instead of the actual return type of thequeryFn
.Your minimal, reproducible example
https://codesandbox.io/p/sandbox/tanstack-react-query-usequeries-skiptoken-issue-wdk8m5
Steps to reproduce
withEnabled.data
andwithSkipToken.data
to see the typesExpected behavior
I expected
withSkipToken.data
to be inferred asnumber | undefined
instead ofunknown
.How often does this bug happen?
None
Screenshots or Videos
No response
Platform
@tanstack/react-query v5.25.0
Tanstack Query adapter
react-query
TanStack Query version
v5.25.0
TypeScript version
v5.3.3
Additional context
No response
The text was updated successfully, but these errors were encountered: