vue-query, refs doesn't work for type narrowing?
I tried to use the type narrowing feature of v5. I prefer to always use refs to not have to keep track of which is which, but then the type narrowing doesn't seem to work?
I posted a screenshot, this is the link with different variants: https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgVwM4FMCKz1QJ5wC+cAZlBCHAOQACMAhgHaoMDGA1gPQBuOAtAEcc+KgFgAUBJh4w6OAFEAHvXAAbOQF5EEuHGAATAFxxGyEACNcAbh0mV6YyyjBGAcxvjCHiawjN4CLbAqAAK6Iz6Lq4ANEGo8lDkULHiusEAysisrOioqCm6LPQwaAVw+sX0xhUMKcRaaFjCeAAUgalwQrh4ANLoeMYA2gBEMLkwwwC6ZV34AGKMxi0AlMYh5CDB6AA8Sipg6gB8cBrH6xRbAHRQuRCq3OhtekZwAIzRdiAOcMP05qzDIjLOrLbziYAkOAtYJhCJRZbaDq+Zh3dCXVQQVwtYYw8KRNzDUESYjoVQYPSQ6HxRLQBHtXTI1Co9GY7HBBJJQkeElkuT0uCM+CKV4ncqVDy6YWXAzciQSCFQ3FwtyXbj0VQ4Om2RnMjFYnGhPFRLnEuCk8kKqkc6Cq9WaxEMvxM9Qs-XsmlQE2eM28h0Cp1CgBMopq9FtGvQErgikD0v0ssk4MpGSyOTyWqRAejAGYQ5Vwzgo4ps3GE-Lk6hMtlcqgC+gM47-NGACx5hh1ovN0vEuVJqFFEq1tURk5aYaoVM1wl+wXRgCsbbDw8LtkUc+7niAA
Is it supposed to require usage of reactive? (no other examples in the docs use reactive, except this specific one) https://tanstack.com/query/latest/docs/vue/typescript#type-narrowing
TypeScript | TanStack Query Docs
Vue Query is now written in TypeScript to make sure the library and your projects are type-safe!
Things to keep in mind:
TS Playground - An online editor for exploring TypeScript and JavaS...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.

3 Replies
noble-gold•2y ago
@nicky_jay same issue for me but when trying to access data in <template> typescript wants me to use .value which is wrong...
DId you solve this at all? maybe downgrading?
other-emerald•2y ago
GitHub
Type narrowing not working in vue 3 template · Issue #5418 · TanSta...
Describe the bug The type narrowing is not working as described in the docs. I am wrapping some content in the template with a v-if="isSuccess" returned from useQuery, but I still have to...
correct-apricot•2y ago
please use #vue-query-questions for, well, questions about vue-query ...