[vue-query] useQuery rejects spreading a queryOptions() result + override since v5.98.0
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- typescript
- Área
- frontend
Línea de trabajo
Comienza con la reproducción mínima en los puntos de entrada queryOptions y useQuery, ejecutando tsc --noEmit o vue-tsc contra las versiones 5.97.0 y 5.98.0+. Traza el branding de queryKey y la inferencia de opciones involucrados en la forma con spread; se considera terminado cuando el ejemplo documentado de spread-and-override pasa la comprobación de tipos sin TS2769, mientras que useQuery(opts) directo sigue siendo válido.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 50.4k
- Forks
- 4.2k
- Merge medio
- 11 h 33 min
- PR fusionados (30 d)
- 421
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TanStack/query
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
TanStack/query#11358 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
solid-query: switching the queryClient accessor strands the new client's cache (subscription stays on the old observer)Posiblemente ocupada @MaNaN1803 la tomó hace 74 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
TanStack/query#11106 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
Los mantenedores suelen responder en 1 día
-
setQueryData: NoInfer loses discriminated-union members when spreading a narrowed updater valuePosiblemente ocupada @iosayin la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Los mantenedores suelen responder en 1 día
-
setQueryData updater loses discriminated-union fields when spreading inferred NoInfer dataPosiblemente ocupada @boriskozak la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
TanStack/query#11794 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/query
Issues similares
-
Upgrade node-libzim to 4.7.0Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
openzim/mwoffliner#2933 ·
Los mantenedores suelen responder en 1 día
-
Use the README category name for website links and submissionsPosiblemente ocupada @dajiaohuang la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
birobirobiro/awesome-shadcn-ui#647 ·
Los mantenedores suelen responder en 2 días
-
Add: Valea Prahovei TV RO SDAbiertocheck:passed streams:add
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Urigo/accounter-fullstack#4604 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día