[vue-query] useQuery rejects spreading a queryOptions() result + override since v5.98.0
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- typescript
- Ambito
- frontend
Direzione di ricerca
Inizia con la riproduzione minima nei punti di ingresso queryOptions e useQuery, eseguendo tsc --noEmit o vue-tsc con le versioni 5.97.0 e 5.98.0+. Traccia il branding di queryKey e l’inferenza delle opzioni coinvolti nella forma con spread; il lavoro è completato quando l’esempio documentato di spread-and-override supera il controllo dei tipi senza TS2769, mentre l’uso diretto di useQuery(opts) rimane valido.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
Since @tanstack/vue-query v5.98.0, the documented pattern of spreading a queryOptions(...) result into useQuery and overriding a non-data-shaping option (e.g. enabled) no longer type-checks. Passing the same options object directly works; only the spread + override form fails.
This is a downstream continuation of #10525. That fix made queryOptions({ queryKey: computed(...) }) type-check again, but the branded queryKey (DataTag<...>) is still inconsistent with the other option properties once the result is spread into a fresh object literal, so useQuery inference fails with TS2769: No overload matches this call.
The most revealing part of the error cascade:
Types of property 'staleTime' are incompatible.
...
Type 'readonly ["activity", "detail", string | null | undefined]' is not assignable to type
'{ ...; [dataTagErrorSymbol]: Error; }'.
Your minimal, reproducible example
import { queryOptions, useQuery } from "@tanstack/vue-query"
import { computed, type MaybeRefOrGetter, toValue } from "vue"
const fooQueryOptions = (id: MaybeRefOrGetter<string | null>) =>
queryOptions({
queryKey: computed(() => ["foo", toValue(id)] as const),
queryFn: async () => {
const v = toValue(id)
return v ? { id: v } : null
},
})
// ✅ OK — passed directly
useQuery(fooQueryOptions("1"))
// ❌ TS2769 since 5.98.0 (works on 5.97.0) — spread + override
useQuery({
...fooQueryOptions("1"),
enabled: () => true,
})
Steps to reproduce
- Install
@tanstack/[email protected](or any version from 5.98.0 onward). - Define a
queryOptions(...)factory with acomputedqueryKey. - Spread its result into
useQuery({ ...opts, enabled: () => true }). - Run
tsc --noEmit/vue-tsc. - TypeScript reports
TS2769: No overload matches this call, bottoming out at thequeryKeymissing thedataTagSymbol/dataTagErrorSymbolbrand.
Note: useQuery(opts) (passing the same options directly, without spreading or overriding) type-checks fine — only the spread + override form fails.
Expected behavior
Spreading a queryOptions(...) result and overriding enabled (or other non-data-shaping options) should type-check, as shown in the docs and as it did on 5.97.0:
https://tanstack.com/query/latest/docs/framework/vue/guides/query-options
How often does this bug happen?
Every time
Screenshots or videos
No response
Platform
- TanStack Query version: broken on 5.98.0 – 5.101.0; last working 5.97.0
- TypeScript version: 5.8+
- Vue version: 3.5+
Additional context
Same class of regression as #10458 (fixed enabled) and #10525 (fixed queryKey on queryOptions), but it surfaces at the useQuery call site when spreading a queryOptions(...) result and overriding a property. Pinning to 5.97.0 produces zero type errors; any of 5.98.0 – 5.101.0 reproduces it.
- Lingua principale
- TypeScript
- Stelle
- 50.4k
- Fork
- 4.2k
- Merge medio
- 11h 33m
- PR unite (30g)
- 421
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/query
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TanStack/query#11358 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
solid-query: switching the queryClient accessor strands the new client's cache (subscription stays on the old observer)Forse già presa @MaNaN1803 l’ha presa 74 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TanStack/query#11106 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
setQueryData: NoInfer loses discriminated-union members when spreading a narrowed updater valueForse già presa @iosayin l’ha presa 1 giorno fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
setQueryData updater loses discriminated-union fields when spreading inferred NoInfer dataForse già presa @boriskozak l’ha presa 1 giorno fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
TanStack/query#11794 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/query
Issue simili
-
level/task reporter/qa type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
wazuh/wazuh-dashboard-plugins#9310 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
cybersemics/treecrdt#267 ·
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
wiz-sec-public/backstage-plugin-wiz#16 · 1 commento ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
solana-foundation/solana-com#2245 ·
I maintainer di solito rispondono entro 1 giorno