Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

vue-query: UseQueryOptions no longer assignable to queryClient.query() since 5.103.0

未關閉
#12,452 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
半天
新手友好度
67/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
typescript

研究方向

Start with the QueryClient overloads for query() and the deprecated prefetchQuery / fetchQuery in the Vue Query adapter, then compare their MaybeRefDeep<...> query function types with UseQueryOptions and the SkipTokenForUseQuery change from #11439. Reproduce the TS2769 error using the issue’s snippet with TypeScript 6.0.3 and Vue Query 5.103.0 or newer. Done when the annotated UseQueryOptions<number> is accepted by these methods and the reported regression is covered by a type check.

由索引模型根據 Issue 內容生成。

描述

Describe the bug

Since 5.103.0, a value typed as UseQueryOptions is no longer accepted by queryClient.query(). It fails with TS2769. The deprecated prefetchQuery / fetchQuery fail the same way.

#11439 added type SkipTokenForUseQuery = symbol to queryFn in UseQueryOptions. The MaybeRefDeep<...> overloads on QueryClient still expect typeof skipToken, so a plain symbol no longer fits. Options inferred through queryOptions() are fine. Only values annotated or cast as UseQueryOptions break, which is what code generators emit.

Your minimal, reproducible example

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgRQK4FMoE8DCAbYdAOxgBo4Ysx04BVAZ3TUywHkwZgIj64BfOADMoEEHADkAARgBDHrIDGAawD0ANwwBaAI4Zs4gFAGAJugV4ZUGgu714EDlx4AuOo2bZ2nWwB4iqEAAjTAA+Ixt5OF0WfEISOABeOCJ0AHcUPVwCYhgACgBKIxUVOBxRMGA8dF5uOABWADoARgAGACYGlvIAFQBlNoB2ADYATjh6YCIFGkbWgGZOgzUIYGMozNichujsXIdvHkKgA

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

declare const options: UseQueryOptions<number>

const queryClient = new QueryClient()

// Compiles on 5.102.0, TS2769 since 5.103.0
void queryClient.query(options)
  1. Install @tanstack/[email protected] or newer
  2. Type-check the snippet
  3. See TS2769
Expected behavior

A UseQueryOptions value is accepted by queryClient.query(), as in 5.102.0.

How often does this bug happen?

Every time

Platform

Type-check only (tsc / vue-tsc), macOS

Tanstack Query adapter

vue-query

TanStack Query version

v5.103.0 (still present in v5.105.0)

TypeScript version

v6.0.3

Additional context

Found through Orval's generated vue-query prefetch*Query helpers, which cast their options to UseQueryOptions before calling queryClient.query().

主要語言
TypeScript
星號
50.5k
分支
4.2k
平均合併
6 小時 27 分鐘
30 天內合併 PR
614

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TanStack/query 的其他 Issue

查看 TanStack/query 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。