[vue-query] useQuery rejects spreading a queryOptions() result + override since v5.98.0
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 55/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- typescript
- Bereich
- frontend
Rechercherichtung
Beginne mit der minimalen Reproduktion an den Einstiegspunkten queryOptions und useQuery und führe tsc --noEmit oder vue-tsc gegen die Versionen 5.97.0 und 5.98.0+ aus. Verfolge das queryKey-Branding und die Optionsinferenz, die an der Spread-Form beteiligt sind; als erledigt gilt es, wenn das dokumentierte Spread-and-Override-Beispiel ohne TS2769 typgeprüft wird, während die direkte Verwendung von useQuery(opts) weiterhin gültig bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 50.4k
- Forks
- 4.3k
- Ø Merge
- 8 Std. 51 Min.
- Gemergte PRs (30 T.)
- 432
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TanStack/query
-
QueryClient.isFetching and useIsFetching accept a fetchStatus filter and ignore itEvtl. vergeben @Apu-Emdad hat das vor 3 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Evtl. wieder frei @LeonxLJX hat das vor 43 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
TanStack/query#11358 · 2 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
solid-query: switching the queryClient accessor strands the new client's cache (subscription stays on the old observer)Evtl. vergeben @MaNaN1803 hat das vor 86 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
TanStack/query#11106 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
solid-query 6.0.0-rc.5: onCacheEvent throws NotReadyError during a Solid 2 (rc.14+) transition landingEvtl. vergeben @UzumakiODZ hat das vor 2 Tagen übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 28/100
TanStack/query#12031 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Explicit gcTime schedules a GC timer during SSR, retaining the whole render in memoryEvtl. vergeben @AdzerKI hat das vor 3 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 25/100
TanStack/query#12025 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
lingdojo/kana-dojo#32663 · 1 Kommentar · 5 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
-
Admin: Title Separator field can't be cleared (input falls back to "|")Evtl. vergeben @emdashbot hat das heute übernommen. Offenbot:bug bot:in-review
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
emdash-cms/emdash#4236 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
PHP workflow streaming requests buffer the full SSE responseEvtl. vergeben @Winoren hat das heute übernommen. Offenreview: medium
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
langgenius/dify#44270 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:holodeck review-finding
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
hyperdrive-technology/holodeck#142 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
code-yeongyu/senpi#3573 ·
Maintainer antworten meist innerhalb von 1 Tag