Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

[vue-query] 5.103.0: UseQueryOptions is no longer assignable to ensureQueryData, fetchQuery and prefetchQuery

Aberta
#11,639 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
74/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
typescript

Direção de pesquisa

Start with the TypeScript definitions for UseQueryOptions and QueryClient's ensureQueryData, fetchQuery, and prefetchQuery entry points, comparing the 5.102.8 and 5.103.0 behavior. Add a regression type test that passes UseQueryOptions with a widened symbol to all three methods, while confirming useQuery still compiles.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Describe the bug

Since 5.103.0, a value typed as UseQueryOptions can still be passed to useQuery, but no longer to the query client's ensureQueryData, fetchQuery or prefetchQuery:

Type 'symbol' is not assignable to type 'MaybeRefDeep<unique symbol | QueryFunction<string, readonly unknown[], never> | undefined>'.

#11439 widened queryFn in UseQueryOptions with SkipTokenForUseQuery = symbol. The query client methods still take query-core's options, whose queryFn accepts only typeof skipToken, a unique symbol. Plain symbol is not assignable to it, so the whole options object is rejected.

This hits generated clients: Orval's vue-query output types every get…QueryOptions() getter as UseQueryOptions, so queryClient.ensureQueryData(getXQueryOptions()), the usual pattern in a router guard, stops compiling.

Your minimal, reproducible example

5.103.2, fails: https://www.typescriptlang.org/play/?ts=6.0.3#code/JYWwDg9gTgLgBAbzgRQK4FMoE8DCAbYdAOxgBo5UBndNTLcmLMdOAVWtuwHkwZgIilOAF84AMygQQcAOQABGAENBSgMYBrAPQA3DAFoAjhmwy4mzXEbNKALjgBWAHQBGAAwBmRwCYAUD4Am6Kp4ilAsqgKU8BC8-IJ27DTGWDx8kQA8UVDARADmAHw+ESpwwYQkcAC8cEToAO4oyfjlMAAUAJR+VEl0rTFpgu1mFhHgwHjolEUExDCOxJSoYZxYACKKSn2xkUPmcJiSUHCUOaosTm6ertMtjmLoMKoAFitbA5S7FgfQx6fnLh5HNcyrNHGAwvdHi9km84h9hvsoIdfkQzg4AVcfEA

5.102.8, compiles: https://www.typescriptlang.org/play/?ts=6.0.3#code/JYWwDg9gTgLgBAbzgRQK4FMoE8DCAbYdAOxgBo5UBndNTLcmLMdOAVWtuwHkwZgIilOAF84AMygQQcAOQABGAENBSgMYBrAPQA3DAFoAjhmwy4mzXEbNKALjgBWAHQBGAAwAmRwA4AUD4Am6Kp4ilAsqgKU8BC8-IJ27DTGWDx8kQA8UVDARADmAHw+ESpwwYQkcAC8cEToAO4oyfjlMAAUAJR+VEl0rTFpgu1mFhHgwHjolEUExDCOxJSoYZxYACKKSn2xkUPmpVJg45NwAg4uHt7TLY5i6DCqABYrWwOUuyMHR0KnTm6evmVZo4wGFbvcnskXnE3sN9mMJt8iGc-pcgA

Steps to reproduce
import { QueryClient, useQuery, type UseQueryOptions } from '@tanstack/vue-query'

declare const options: UseQueryOptions<string>
const client = new QueryClient()

useQuery(options) // compiles
client.ensureQueryData(options) // error since 5.103.0
client.fetchQuery(options) // error since 5.103.0
client.prefetchQuery(options) // error since 5.103.0
Expected behavior

Options that useQuery accepts are also accepted by ensureQueryData, fetchQuery and prefetchQuery, as in 5.102.8.

How often does this bug happen?

Every time

Platform
  • OS: macOS 26 and Ubuntu (GitHub Actions)
  • Browser: none, this is a compile-time error from tsc and vue-tsc
  • Version: n/a
Tanstack Query adapter

vue-query

TanStack Query version

v5.103.2

TypeScript version

v6.0.3

Additional context

#11439's new type tests cover useQuery and queryOptions, but none passes UseQueryOptions to a query client method. Passing a literal skipToken to ensureQueryData still compiles. Only the widened symbol fails.

Linguagem predominante
TypeScript
Estrelas
50.4k
Forks
4.2k
Merge médio
23h 7min
PRs com merge (30d)
231

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de TanStack/query

Todas as issues de TanStack/query

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.