fix: infer pageParam from computed queryFn with conditional skipToken#10335
fix: infer pageParam from computed queryFn with conditional skipToken#10335danieljayasurya-e wants to merge 4 commits intoTanStack:mainfrom
Conversation
📝 WalkthroughWalkthroughUpdated typings for Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx affected --targets=test:sherif,test:knip,tes... |
❌ Failed | 1m 26s | View ↗ |
nx run-many --target=build --exclude=examples/*... |
❌ Failed | 19s | View ↗ |
☁️ Nx Cloud last updated this comment at 2026-04-03 14:18:16 UTC
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/vue-query/src/useInfiniteQuery.ts (1)
56-69: Consider aligninguseQueryanduseInfiniteQueryqueryFnoption ergonomics.
UseInfiniteQueryOptionsnow supports getter-wrappedqueryFn, butUseQueryOptionsstill handles all non-enabledproperties throughMaybeRefDeep(seepackages/vue-query/src/useQuery.ts, Line 22-52). A follow-up alignment could reduce API surprise across Vue Query hooks.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/vue-query/src/useInfiniteQuery.ts` around lines 56 - 69, The UseInfiniteQueryOptions typing in useInfiniteQuery.ts treats the queryFn property as MaybeRefOrGetter but other options still use MaybeRefDeep, causing inconsistency with useQuery; update the UseQueryOptions (in useQuery.ts) or align useInfiniteQuery's generics so both hooks accept getter-wrapped queryFn the same way: ensure the QueryOptions generic mapping uses MaybeRefOrGetter for the 'queryFn' property (reference symbols: useInfiniteQuery, UseInfiniteQueryOptions, queryFn, useQuery, UseQueryOptions, MaybeRefDeep, MaybeRefOrGetter) so the two hooks have matching ergonomics for getter-wrapped query functions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/vue-query/src/useInfiniteQuery.ts`:
- Around line 56-69: The UseInfiniteQueryOptions typing in useInfiniteQuery.ts
treats the queryFn property as MaybeRefOrGetter but other options still use
MaybeRefDeep, causing inconsistency with useQuery; update the UseQueryOptions
(in useQuery.ts) or align useInfiniteQuery's generics so both hooks accept
getter-wrapped queryFn the same way: ensure the QueryOptions generic mapping
uses MaybeRefOrGetter for the 'queryFn' property (reference symbols:
useInfiniteQuery, UseInfiniteQueryOptions, queryFn, useQuery, UseQueryOptions,
MaybeRefDeep, MaybeRefOrGetter) so the two hooks have matching ergonomics for
getter-wrapped query functions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 36c8c7bf-8625-49b3-a41d-ef16a4aa99e6
📒 Files selected for processing (1)
packages/vue-query/src/useInfiniteQuery.ts
|
test are failing, seems related |

🎯 Changes
This PR fixes a Vue Query type inference issue in useInfiniteQuery when queryFn is provided through a computed wrapper,
especially in conditional skipToken cases.
Previously, TypeScript could lose contextual typing for the computed queryFn, causing pageParam to fall back to unknown even when initialPageParam clearly established its type. This change makes the queryFn option preserve contextual typing in that shape by explicitly typing the property and widening the skipToken branch to a generic symbol for inference
purposes.
The PR also adds a regression type test covering computed(() => enabled ? ({ pageParam }) => ... : skipToken) to ensure
pageParam and lastPageParam remain strongly typed.
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit