-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
refactor: remove unnecessary TQueryData generic in InfiniteQueryObserverOptions #9224
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
refactor: remove unnecessary TQueryData generic in InfiniteQueryObserverOptions #9224
Conversation
…): remove unnecessary TQueryData in InfiniteQueryObserverOptions
View your CI Pipeline Execution ↗ for commit e368b11.
☁️ Nx Cloud last updated this comment at |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9224 +/- ##
===========================================
+ Coverage 45.37% 59.66% +14.28%
===========================================
Files 209 138 -71
Lines 8267 5511 -2756
Branches 1864 1479 -385
===========================================
- Hits 3751 3288 -463
+ Misses 4076 1925 -2151
+ Partials 440 298 -142 🚀 New features to boost your workflow:
|
I wanted to get this done for so long but couldn’t fully wrap my head around it. Thank you 🙏 |
…finiteQueryObserverOptions
btw @braden-w if you’re on Discord, I’d love to connect ❤️ . Let me know if you plan to stick around, your contributions are awesome 🙌 |
Amazing, thank you @TkDodo for your work and comments on my previous PRs!! This week is busy but I'll do my best to update them sometime next week :) and would love to connect on Discord! I just sent you a message and friend request. |
Hey @braden-w @TkDodo, this change turns out to be a breaking change. At least for folks like us that work with the |
Thanks for flagging. I’m very cautious about accidental breaking changes, but it’s not really feasible doing that for types, too. We’ve noted that here: https://tanstack.com/query/v5/docs/framework/react/typescript
|
Thanks @TkDodo that's totally fair. We'll figure something out. This one has meaningful impact for folks building libraries of hooks that wrap react query primitives. Especially painful if it means going from peer dependency of My current plan is to inline the type in my library. It should break the dependency on |
This PR simplifies
InfiniteQueryObserverOptions
by removing the unnecessaryTQueryData
generic parameter.For infinite queries, the actual data stored in the cache is the per-page data (defined by
TQueryFnData
) wrapped within anInfiniteData
structure:InfiniteData<TQueryFnData, TPageParam>
.The previous definition of
InfiniteQueryObserverOptions
introduced an intermediate generic,TQueryData
, which was defaulted toTQueryFnData
. ThisTQueryData
was then used to define the cached structure asInfiniteData<TQueryData, TPageParam>
.This intermediate
TQueryData
step was redundant because the type of the data for each page (TQueryFnData
) is already known. The cached data structure can therefore directly useTQueryFnData
.This change removes the
TQueryData
generic, simplifying the type signature:This simplification reduces complexity and makes the type definition more direct.
The update has been consistently applied across:
packages/query-core/src/types.ts
(notablyInfiniteQueryObserverOptions
andDefaultedInfiniteQueryObserverOptions
).InfiniteQueryObserver
class inpackages/query-core/src/infiniteQueryObserver.ts
.infiniteQueryOptions
,UseInfiniteQueryOptions
) in framework packages (react-query
,vue-query
,solid-query
,angular-query-experimental
).