-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(types): useSuspenseQuery should type-narrow the Error field #9105
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
Conversation
View your CI Pipeline Execution ↗ for commit 0273210.
☁️ Nx Cloud last updated this comment at |
@@ -155,7 +156,7 @@ export type UseQueryResult< | |||
export type UseSuspenseQueryResult< | |||
TData = unknown, | |||
TError = DefaultError, | |||
> = OmitKeyof< | |||
> = DistributiveOmit< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manudeli I think your OmitKeyof
helper doesn’t work over union types (just like the build-in Omit
also doesn’t work with it).
Because DefinedQueryObserverResult
is a union of:
| QueryObserverRefetchErrorResult<TData, TError>
| QueryObserverSuccessResult<TData, TError>
it “doesn’t work” in a sense that type narrowing to error
doesn’t happen anymore because it’s not distributive.
I’ve added the standard DistributiveOmit
helper and things work fine, but if you can improve your helper type to not fail the added test case, we can switch back.
Sizes for commit 0273210:
|
Co-authored-by: Jonghyeon Ko <[email protected]>
query/packages/vue-query/src/types.ts Lines 58 to 60 in 89846b7
I think the DistributiveOmit from this line in Vue Query can be removed as well |
done: 5cd8471 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9105 +/- ##
===========================================
+ Coverage 44.50% 58.78% +14.28%
===========================================
Files 204 139 -65
Lines 8150 5404 -2746
Branches 1820 1437 -383
===========================================
- Hits 3627 3177 -450
+ Misses 4080 1927 -2153
+ Partials 443 300 -143 🚀 New features to boost your workflow:
|
No description provided.