Skip to content

[vue-query]: invalid inferred type for computed queryKey readonly unknown[] in queryOptions #7420

@MellKam

Description

@MellKam

Describe the bug

import { queryOptions } from "@tanstack/vue-query"
import { computed } from "vue"

queryOptions({
    queryKey: ["hello"],
    queryFn: ({ queryKey }) => {
        queryKey
        // ^? (parameter) queryKey: string[]
    }
})

queryOptions({
    queryKey: computed(() => ["hello"]),
    queryFn: ({ queryKey }) => {
        queryKey
        // ^? (parameter) queryKey: readonly unknown[]
		// the type should be the same as in the first example without computed
    }
})

I noticed this after upgrading to the latest version of vue-query (5.35.5) from 5.29.0

Your minimal, reproducible example

typescript playground reproduction

Tanstack Query adapter

vue-query

TanStack Query version

5.35.5

TypeScript version

5.4.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions