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
{{ message }}
Repository navigation
Branded queryKey in queryOptions causes TS error (TS2769) in useQuery #9920
I’m encountering a TypeScript overload mismatch (TS2769) when calling useQuery() with the result of a queryOptions(...) function whose returned object contains a queryKey with a branded type. The error occurs specifically when useQuery() receives the output of queryOptions(...) containing a branded value in queryKey.
Passing the same options to queryClient.fetchQuery(queryOptions(queryKey: brandedKey, queryFn)) — works fine.
Passing the branded key inline to useQuery (i.e. useQuery({ queryKey: brandedKey, queryFn})) — works fine.
3. Call useQuery() using the result of this helper:
useQuery(getPostQueryOptions({ postId }));
4. Observe the TypeScript error:
No overload matches this call.
Overload 1 of 3, '(options: DefinedInitialQueryOptions<Post, Error, Post, MaybeRefDeep<string | (() => { postId: PostId; }) | { postId: PostId; }>[]>, queryClient?: QueryClient | undefined): UseQueryDefinedReturnType<...>', gave the following error.... ts(2769)
Expected behavior
useQuery() should correctly accept a QueryOptions object whose queryKey contains a branded (nominal) type.
In other words:
Passing the result of queryOptions(...) or any helper function that returns a QueryOptions object should not trigger a TypeScript overload error, even if the queryKey includes branded values.
How often does this bug happen?
Every time
Screenshots or Videos
Platform
OS [Windows]
Browser [Chrome]
Tanstack Query adapter
vue-query
TanStack Query version
v5.85.3
TypeScript version
v5.9.2
Additional context
No response
Reacted by Ilya Golovin, Filimon Mikhail and Alexander Ryzhikh
Error: Type '(string | number)[]' is missing the following properties from type '... & { [dataTagSymbol]: ...; [dataTagErrorSymbol]: ...; }': [dataTagSymbol], [dataTagErrorSymbol]
Additional production data point that may help prioritize this:
We just attempted to upgrade @tanstack/vue-query from 5.97.0 → 5.100.11 on a Nuxt 4 codebase (~24 files using the spread-and-override pattern). The upgrade is blocked specifically by this regression, and the impact is narrow but real:
Impact in our codebase: 3 out of 24 spread-and-override hooks fail TS2769. The other 21 happen to pass because their type shape doesn't trigger the issue.
Property access preserves the branded queryKey type, while spread + extra props loses it through MaybeRefDeep. This matches the root cause #10573 identifies.
We're unblocked via the workaround, but having #10573 (or equivalent) land would let us delete the explicit-field workaround and restore the idiomatic spread pattern — which is what the official TanStack Vue docs recommend.
Happy to share the failing file paths / a minimal repro if it helps. The reproduction in the issue body already covers the essential case; this is mostly a "+1, real-world frequency" data point.
I'm upgrading from 5.92 and seeing something similar.
Although I don't use branded types; my issue manifests when using keys containing a ref/computed.
The issue first appeared on 5.95 and it still occurs on 5.102.8.
For me, wrapping the whole query key in a computed fixes and unwrapping the param seems to have helped 🤞
// before: functionmyQueryOptions(foo: MaybeRef<string>){queryOptions({queryKey: ['bar',toRef(foo)]// ❌ this fails...})}//afterfunctionmyQueryOptions(foo: MaybeRef<string>){queryOptions({queryKey: computed(()=>['bar',toValue(foo)])// ✅ this seems works...})}
Activity
DamianOsipiuk commentedon Nov 27, 2025
Hmm it seems that
brandedtype is conflicting withDataTag. If i remove it fromqueryOptionssignature then TS error goes away.Not sure about the fix.
fix(vue-query): preserve branded types in MaybeRefDeep
xerox0213 commentedon May 14, 2026
I'm experiencing a similar TS2769 error when spreading queryOptions with an extra enabled property inside a Vue computed():
useQuery( computed(() => ({ ...myQueryOptions(params), enabled: someCondition, })) )Error: Type '(string | number)[]' is missing the following properties from type '... & { [dataTagSymbol]: ...; [dataTagErrorSymbol]: ...; }': [dataTagSymbol], [dataTagErrorSymbol]
KIM-DONGJU commentedon May 20, 2026
Additional production data point that may help prioritize this:
We just attempted to upgrade
@tanstack/vue-queryfrom 5.97.0 → 5.100.11 on a Nuxt 4 codebase (~24 files using the spread-and-override pattern). The upgrade is blocked specifically by this regression, and the impact is narrow but real:Impact in our codebase: 3 out of 24 spread-and-override hooks fail TS2769. The other 21 happen to pass because their type shape doesn't trigger the issue.
Pattern that fails:
Failing cases share at least one of these traits (based on bisecting which 3 of 24 fail):
boolean) —dataTagSymbol: booleanbrand on the queryKey seems particularly fragile throughMaybeRefDeepmappingrefetchIntervalis set alongside the spread — its generic instantiation re-references the branded queryKey shape, triggering the mismatchWorkaround we shipped: dropping the spread in favor of explicit field forwarding works around it:
Property access preserves the branded
queryKeytype, while spread + extra props loses it throughMaybeRefDeep. This matches the root cause #10573 identifies.We're unblocked via the workaround, but having #10573 (or equivalent) land would let us delete the explicit-field workaround and restore the idiomatic spread pattern — which is what the official TanStack Vue docs recommend.
Happy to share the failing file paths / a minimal repro if it helps. The reproduction in the issue body already covers the essential case; this is mostly a "+1, real-world frequency" data point.
fix(vue-query): preserve branded types in MaybeRefDeep
basuneko commentedon Sep 22, 2026
I'm upgrading from 5.92 and seeing something similar.
Although I don't use branded types; my issue manifests when using keys containing a ref/computed.
The issue first appeared on 5.95 and it still occurs on 5.102.8.
For me, wrapping the whole query key in a computed fixes and unwrapping the param seems to have helped 🤞