Skip to content
Source
Sign inSign up
TanStack/query

Incorrect type for `getNextPageParam` in `vue-query`'s `useInfiniteQuery` #6177

Send to my agent
Closedzqianem(GitHub profile, opens in a new tab) opened this issue 5 comments

Describe the bug

When calling useInfiniteQuery, the type of the first parameter to the getNextPageParam option was previously inferred from the return type of queryFn; this is no longer the case and the type defaults to unknown.

Your minimal, reproducible example

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgVwM4FMCSA7AZsbYGdARWXSgE84BfOXKCEOAcgAEYBDbVLgYwDWAegBu5ALQBHclRYBYAFCK0WPASKkZlABQJFcONIqUA0ukoAuOAG0WuCBBYBdADT646mME4AbAAqcAOboAVCcIFYADG4KBkZUAGLYVrpwYEEhnGHMNACUcAC8AHz06DB8ABbaAAYVMDBgqBZCQugAHuFgPugAdHxMQgAkCOnBoeE01bkxBsEwAHLtMAFjWeEpPpy8K+j5xXDam9sZPRACcAD8cACMcFbYyD4+uYp5QA

Steps to reproduce

  1. Visit example
  2. See 'lastPage' is of type 'unknown'. in the Errors tab

Expected behavior

As a user, I expected the type in the example to be Response, but the type is actually unknown.

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

n/a

Tanstack Query adapter

None

TanStack Query version

v5.0.0

TypeScript version

v5.2.2

Additional context

Possibly related to #6174 — this error also goes away when using react-query instead of vue-query.

  1. TkDodo added labelsbug

  2. TkDodo added labelstypes

  3. TkDodo added labelspackage: vue-query

  4. Looks like issue is still there but with queryFn. queryFn doesn't see what type you return.

  5. This seems to have regressed in react now. I'm getting the exact same issue (and https://github.com/TanStack/query/issues/6177#issuecomment-1768763417 doesn't fix it)

    UPDATE: Sorry, just realised this is happening in prefetchInfiniteQuery - will raise a new issue

Sign in to join this conversation.