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
In the old, separate vue-query package, using vue's reactive on the return of useQuery preserved the union return type, but now all the union types seem to get combined into one type. This means you can't narrow types based on e.g. isSuccess.
Hover over query.data and notice it's been narrowed to string
Hover over queryNew.data and notice it hasn't been narrowed and is string | undefined
Hover over query and notice it's a union type
Hover over queryNew and notice it's not a union type
Expected behavior
I expected @tanstack/vue-query to have the same behavior as vue-query so that I can discriminate between union types.
How often does this bug happen?
Every time
Screenshots or Videos
Platform
OS: Linux
Browser: N/A
Version: N/A
react-query version
4.17.1 for @tanstack/vue-query, 1.26.0 for vue-query
TypeScript version
4.8.4
Additional context
No response
The text was updated successfully, but these errors were encountered:
henribru
changed the title
Vue reactive call no longer preserves union type of vue-query' useQuery
Vue reactive call no longer preserves union type of vue-query's useQuery
Nov 26, 2022
Describe the bug
In the old, separate vue-query package, using vue's
reactive
on the return ofuseQuery
preserved the union return type, but now all the union types seem to get combined into one type. This means you can't narrow types based on e.g.isSuccess
.Your minimal, reproducible example
I attempted to reproduce this in the Typescript Playground, but for whatever reason it just shows me
any
for the return type of the olduseQuery
... https://www.typescriptlang.org/play?ts=4.8.4#code/JYWwDg9gTgLgBAbzlApgQwMY2ANxXAXzgDMoIQ4AiHAVxUoG4AoUSWROGgZxQEU6oAT0IkyFAOS0UAWgCOAweOato8JNz4K4aLpx78UQgHIoA7iNLk44gAIw0AOy72MAawD0UuQqVMmxGgcsYAgHEggIAAoASkQmOATkFBgaKDCABTFgHgA6VC4IABs8SMpiCMpopgI-DFDnOHlDYQBeJMxsEo0DIUiAbTKKgF0AGnCIaOjmJqEcgBM0exZiOEiZwRzsgGUaDAwULi5YhHjE9fnFtGra+vh1k3M21A7cFEjuhQf+wYhKUfHJtMFBclsAVmtPmZNlwdnsDkc4olGpDTCCrgQgAI've made a local reproduction you can clone instead: https://github.com/henribru/vue-query-use-query-reactive/blob/master/src/main.ts
Steps to reproduce
query.data
and notice it's been narrowed to stringqueryNew.data
and notice it hasn't been narrowed and isstring | undefined
query
and notice it's a union typequeryNew
and notice it's not a union typeExpected behavior
I expected
@tanstack/vue-query
to have the same behavior asvue-query
so that I can discriminate between union types.How often does this bug happen?
Every time
Screenshots or Videos
Platform
react-query version
4.17.1 for @tanstack/vue-query, 1.26.0 for vue-query
TypeScript version
4.8.4
Additional context
No response
The text was updated successfully, but these errors were encountered: