v5: infiniteQuery incorrectly infers unknown as data when used with select #5881
Send to my agentDescribe the bug#
createInfiniteQuery infers unknown for QueryFnData
Your minimal, reproducible example#
https://codesandbox.io/p/sandbox/nostalgic-matan-nrdklh
Steps to reproduce#
- use
createInfiniteQuery - Provide the required fields for the query options
- The inferred query data for the pages is
unknown[]
Expected behavior#
createInfiniteQuery to infer querFn return type as the query data type
How often does this bug happen?#
Always
Screenshots or Videos#
No response
Platform#
-OS: Linux
Tanstack Query adapter#
solid-query
TanStack Query version#
v5
TypeScript version#
v5.1.6
Additional context#
No response
you are right, it seems to be a general issue with
selecton infinite queries. Here is a typescript playground showing the same issue for react.@ecyrbe could you maybe take a look at this?
TkDodo changed the title
TkDodo added labelsbug
TkDodo added labelshelp wanted
TkDodo added labelstypes
TkDodo added labelspackage: query-core
@TkDodo on it, did something change since we added the feature ? i remember we added type checking tests for this. Any regression should have been caught.
@ecyrbe I'm not sure, but we certainly haven't deleted any tests. So I think we probably don't have a test for this case.
@TkDodo on my side, all type tests are broken. i don't know how they are passing in CI/CD. Something broke the whole thing. i'm not sure where this regression came from. still on it.
@TkDodo ok i found the origin of the issue, it was a change made 3 weeks ago to remove suspense from the resulting infinitte query options, just ordering the Omit properly like this fixes the issue :
There is still an issue with the type tests as they are ignored by ci/cd. i guess it's because typeschecking is disabled in tests. i strongly suggest to get it back. else these kind of regressions will get incognito into someones production.
@lachlancollins can you take a look why the tests are excluded from type checks in ci/cd? My guess is because we only use
tscnow to produced.tsoutput, and tests are not included? However, we should really have a check where all typescript files are checked for correctness.TkDodo closed this
There is still an issue with the type tests as they are ignored by ci/cd
@ecyrbe I've investigated this a bit more. If I revert your change, all type tests pass. If I change something inside one of the type tests, it is correctly reported as failure. Could it be that we just didn't have a test for this case? I think there's nothing wrong with our CI setup ...
Sign in to join this conversation.
Possibly related issue: infiniteQueryOptions in react-query also seems to incorrectly infer the data type without the InfiniteData wrapper, which provides the individual pages.