-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix(react-query): improve useQueries select inference #10051
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
base: main
Are you sure you want to change the base?
Conversation
Fixes TanStack#6556. Also refactors queryOptions/infiniteQueryOptions overload return types to named *Result aliases to reduce TS4023 'cannot be named' issues for exported options objects (see TanStack#8453).
|
📝 WalkthroughWalkthroughThis PR improves TypeScript type inference for the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 |
Summary
This PR addresses two TypeScript typing issues in
@tanstack/react-query:selectworks differently onuseQueriescompared touseQuery#6556:useQueries/useSuspenseQueriescould lose type inference for theselectcallback input (degrading toany/unknown) when options were provided without explicit generics.queryOptions()/infiniteQueryOptions()could trigger TS4023 ("cannot be named") in consumer declaration output.Changes
useQueriesanduseSuspenseQueriessoTQueryFnDatais derived from thequeryFnreturn type andTDatafrom theselectoutput, restoring correctselect(data)contextual typing.queryOptions/infiniteQueryOptionsoverload return types to named*Resultaliases to make declaration output more stable.selectparameter annotations.Tests
pnpm -C packages/react-query run test:types:tscurrentFixes #6556.
Addresses #8453.
Summary by CodeRabbit
Release Notes
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.