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
[vue-query] queryOptions rejects computed ref as queryKey since v5.98.0 #10525
Since @tanstack/vue-queryv5.98.0 (PR #10452), passing a ComputedRef (or any reactive value) as queryKey to queryOptions no longer type-checks. This is the same class of regression as #10458 (which only fixed the enabled property), but it affects queryKey too — and the fix PR #10465 did not address it.
The symptom is a large TS2769: No overload matches this call error. The most revealing part of the error message is:
Object literal may only specify known properties, and 'queryKey' does not exist in type
'() => UndefinedInitialQueryOptions_alias_1<unknown, Error, unknown, readonly unknown[]>'.
TypeScript picks the getter-style overload (options: () => ...) because computed(...) isn't assignable to the plain QueryKey position on the object-style overload. This is exactly the same root cause identified in CodeRabbit's comment on #10452: #10452 (comment)
The downstream cascade also produces misleading errors about staleTime being StaleTimeFunction<...> vs MaybeRefDeep<StaleTimeFunction<...>>, and queryKey missing dataTagSymbol / dataTagErrorSymbol brand properties.
Your minimal, reproducible example
Minimal code that fails on 5.98.0, 5.99.0, 5.99.1, and 5.99.2:
import{queryOptions}from"@tanstack/vue-query"import{computed,typeMaybeRefOrGetter,toValue}from"vue"exportconstfooQueryOptions=(id: MaybeRefOrGetter<string|null>)=>queryOptions({// ❌ TS2769 since 5.98.0 — works on 5.97.0queryKey: computed(()=>["foo",toValue(id)]asconst),queryFn: async()=>{constidValue=toValue(id)returnidValue ? {id: idValue} : null},})
The fix should mirror what #10465 did for enabled — adjust the input type of queryOptions so queryKey accepts MaybeRefDeep<QueryKey> / ComputedRef<QueryKey> in addition to plain QueryKey.
How often does this bug happen?
Every time.
Screenshots, code snippets, OS, etc.
Affected versions: 5.98.0, 5.99.0, 5.99.1, 5.99.2 (latest). Last working version: 5.97.0.
Verified locally in a project with ~80 queryOptions usages: pinning to 5.97.0 produces zero type errors; upgrading to any of 5.98.0 – 5.99.2 yields 83 TS2769 errors, all originating from the same pattern.
Activity
fix(vue-query): allow computed ref as queryKey property in queryOptions
fix(vue-query): allow computed ref as queryKey property in queryOptio…