query
query copied to clipboard
pageParam missing from default queryFn typescript definition
Describe the bug
pageParam used to be available in the default queryFn parameter options. It is still passed (it is working correctly with //@ts-ignore), but typescript is reporting the following error when using it:
Property 'pageParam' does not exist on type '{ queryKey: QueryKey; signal: AbortSignal; meta: Record<string, unknown> | undefined; }'
Your minimal, reproducible example
https://tanstack.com/
Steps to reproduce
- create a default query function in a typescript project
- try to add a pageParam parameter
Expected behavior
pageParam is present in the typescript definition
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
all
Tanstack Query adapter
react-query
TanStack Query version
5.17.12
TypeScript version
4.9.5
Additional context
No response
we wanted to avoid having pageParam
be available on useQuery
, so it's only there on useInfiniteQuery
. But yeah, that influences the global queryFn. Seems like we need to remove that conditional type. Do you want to contribute that?
I can have a look yes !
@TkDodo shouldn't we have two default functions instead? One for the normal query and one for the infinite one ?
I'm also running into this as well :)
would be nice of course to fix/extend the typescript definition QueryFunctionContext for useInfiniteQuery to include the extra parameters it received, pageParam most important haha.
@TkDodo shouldn't we have two default functions instead? One for the normal query and one for the infinite one ?
that's not possible. There is only one queryFn
in defaultOptions
I'm also running into this as well :)
what can we do in the meanwhile?