fix: infer pageParam from computed queryFn with conditional skipToken#10335
fix: infer pageParam from computed queryFn with conditional skipToken#10335danieljayasurya-e wants to merge 1 commit intoTanStack:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughEnhanced type inference for Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 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 |
🎯 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
useInfiniteQueryto properly support conditional query functions with skip tokens in computed properties.