Skip to content
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

pageParam missing from default queryFn typescript definition #6715

Closed
rmanibus opened this issue Jan 16, 2024 · 6 comments · Fixed by #7212
Closed

pageParam missing from default queryFn typescript definition #6715

rmanibus opened this issue Jan 16, 2024 · 6 comments · Fixed by #7212
Labels
bug Something isn't working types

Comments

@rmanibus
Copy link

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

  1. create a default query function in a typescript project
  2. 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

@TkDodo TkDodo added bug Something isn't working types labels Jan 16, 2024
@TkDodo
Copy link
Collaborator

TkDodo commented Jan 20, 2024

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?

@rmanibus
Copy link
Author

I can have a look yes !

@rmanibus
Copy link
Author

@TkDodo shouldn't we have two default functions instead? One for the normal query and one for the infinite one ?

@bwhitt
Copy link

bwhitt commented Mar 27, 2024

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
Copy link
Collaborator

TkDodo commented Mar 27, 2024

@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

@shanicloudinary
Copy link

I'm also running into this as well :)

what can we do in the meanwhile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants