Skip to content

queryOptions() helper using select doesn't type-check when used with useQueries #6442

@larrifax

Description

@larrifax

Describe the bug

I'm trying to use a QueryOptions object created with the new queryOptions() helper in a useQueries() call.
This doesn't typecheck as long as the options object contains a select-fn where the return type doesn't equal the return type of the queryFn.

It works fine when the same options object is used in a useQuery(). Same story with useSuspenseQueries() and useSuspenseQuery()

Your minimal, reproducible example

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgRwK4FMoE8DyYbAQB2AzgDRyonoCKG2FVt9w6JcAvnAGZQQhwARAAEYAQ1LiAxgGsA9FHRipMALRpMWQQChtU4iXgbsAaXRY4AXjgAKAJRWAfHADagmecEBdPQaP0sADEiK1sHS2cABT4QYGoAOkUSCAAbADd0GwBGO19JFACAZXQU9BVoUJsAEzFxAC44IlQQACNMcOca8ThnLN19fIh8QlJQ41xhgxsEbTgCzTMsBvHF+zJZ+exg5YDg9bnqUpUdzWKjmGh1jjsAbn6-Taws0KY6TRshggNb+-zxgCYXtQ3lBWCRppswQ0XJ8RiQvJwfkA

Steps to reproduce

  1. Hover over the error reported in the useQueries call in query2
  2. Observe that it is expecting select to return the same type as queryFn

Expected behavior

I would expect that the useQueries call would type-check the same way as the useQuery call

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

Any platform

Tanstack Query adapter

react-query

TanStack Query version

5.8.7

TypeScript version

5.3.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtypes

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions