Description
Describe the bug
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
.
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 old useQuery
... https://www.typescriptlang.org/play?ts=4.8.4#code/JYWwDg9gTgLgBAbzlApgQwMY2ANxXAXzgDMoIQ4AiHAVxUoG4AoUSWROGgZxQEU6oAT0IkyFAOS0UAWgCOAweOato8JNz4K4aLpx78UQgHIoA7iNLk44gAIw0AOy72MAawD0UuQqVMmxGgcsYAgHEggIAAoASkQmOATkFBgaKDCABTFgHgA6VC4IABs8SMpiCMpopgI-DFDnOHlDYQBeJMxsEo0DIUiAbTKKgF0AGnCIaOjmJqEcgBM0exZiOEiZwRzsgGUaDAwULi5YhHjE9fnFtGra+vh1k3M21A7cFEjuhQf+wYhKUfHJtMFBclsAVmtPmZNlwdnsDkc4olGpDTCCrgQgA
I'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
- Open up src/main.ts in e.g. VS Code
- Hover over
query.data
and notice it's been narrowed to string - Hover over
queryNew.data
and notice it hasn't been narrowed and isstring | 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