Skip to content

[vue-query]: queryOptions unassignable type #6299

@NoeReverse

Description

@NoeReverse

Describe the bug

I tried using queryOptions as the documentation says, to use the same parameters in the useQuery and the queryClient.fetchQuery. When I use the queryOptions in the useQuery, everything looks fine, but when I try to use it in the fetchQuery, an error "Argument of type <...> is not assignable to parameter of type <...>" occurs.

Your minimal, reproducible example

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgVwM4FMCKz1QJ4A0KG2ueAwgDbDoB2MRAjjvgPJgzAS2pwC+cAGZQIIOAHIAAjACGPWQGMA1gHoAbjgC0zMuICwAKEODktBZ25wQeUvgBitABQBKRIbhwo6GMii04AAoiIMAYAHReqBCUauiO4oIQEOLOhnyGxqbmXP4A5iLIYOwWPC5uBh5ePn5wOmwcOaiOCO4etSx4ANLoeABccADa4jDoqDDiALoErR51eA791rbztK18qQbpRgZoWB2O+RCFxY0uG4YK3GPtZFQ09HAAvMR7t9R0MC6GMgDuMsDwOZ3D5hQTeBQAC2WBwKRQaVzOQA

Steps to reproduce

  1. Go to reproducible example link
  2. See the error in the last line

Expected behavior

I was expecting to be able to use shareable parameters in both the useQuery composable and the fetchQuery function, but I can't because of a TypeScript error

How often does this bug happen?

Every time

Screenshots or Videos

image

Platform

Windows 11, Node v21.1.0, Nuxt 3

Tanstack Query adapter

vue-query

TanStack Query version

v5.4.3

TypeScript version

v5.2.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions