You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(vue-query): preserve discriminated union narrowing in UseBaseQueryReturnType (#9244)
Make the mapped type explicitly distributive over each variant of
QueryObserverResult, and lock in the narrowing patterns that work
without reactive() (direct data.value !== undefined check) versus
those that require reactive() (narrowing via isSuccess / status).
Fixes#9244
Generated by Claude Code
Vibe coded by ousamabenyounes
Co-Authored-By: Claude <noreply@anthropic.com>
fix(vue-query): preserve discriminated union narrowing in `UseBaseQueryReturnType`
6
+
7
+
Make the mapped type explicitly distributive over each variant of `QueryObserverResult`, and document the narrowing patterns that work without `reactive()` (direct `data.value !== undefined` checks) versus those that require `reactive()` (narrowing via `isSuccess`/`status`). Adds type-test coverage for the issue scenario.
> **Note:** Wrapping `useQuery(...)` in `reactive(...)` is required to narrow `data` from a discriminator like `isSuccess` or `status`. Destructuring directly from `useQuery(...)` produces independent refs, and TypeScript cannot propagate narrowing across separate refs — `if (isSuccess.value)` will not narrow `data.value` from `T | undefined` to `T`. If you cannot use `reactive()`, narrow the value ref directly with `if (data.value !== undefined)`.
0 commit comments