Skip to content

fix(tanstack-query): propagate TPageParam generic through useInfiniteFindMany#1

Draft
Copilot wants to merge 2 commits intodevfrom
copilot/fix-infinite-query-type-inference
Draft

fix(tanstack-query): propagate TPageParam generic through useInfiniteFindMany#1
Copilot wants to merge 2 commits intodevfrom
copilot/fix-infinite-query-type-inference

Conversation

Copy link

Copilot AI commented Mar 1, 2026

TPageParam was not threaded through useInfiniteFindMany (and suspense variants), causing lastPageParam, pageParams, and getNextPageParam callback parameters to fall back to unknown regardless of what the user provided.

Changes

  • ModelInfiniteQueryOptions<T, TPageParam> – added TPageParam = unknown generic and forwarded it to the underlying UseInfiniteQueryOptions (positions 4 & 5), in all three adapters (React, Vue, Svelte)
  • ModelSuspenseInfiniteQueryOptions<T, TPageParam> – same treatment for the React suspense variant
  • useInfiniteFindMany / useSuspenseInfiniteFindMany interface signatures – added TPageParam = unknown so TypeScript can infer the page param type from the getNextPageParam callback
  • useInternalInfiniteQuery / useInternalSuspenseInfiniteQuery – updated generics and cast initialPageParam: args as TPageParam (args is unknown at the impl level but always matches at the call site)

Before / After

// Before: lastPageParam and pageParams are unknown
const result = client.user.useInfiniteFindMany({}, {
    getNextPageParam: (_last, _all, lastPageParam) => lastPageParam, // lastPageParam: unknown
});
result.data?.pageParams[0]?.cursor; // TS error — unknown has no .cursor

// After: TPageParam is inferred from the callback signature
const result = client.user.useInfiniteFindMany({}, {
    getNextPageParam: (_last, _all, lastPageParam: { cursor: string }) => lastPageParam,
});
result.data?.pageParams[0]?.cursor; // ✓ string

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: motopods <58200641+motopods@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix lastPageParam type inference in useInfiniteFindMany fix(tanstack-query): propagate TPageParam generic through useInfiniteFindMany Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants