Skip to content

useQueries data typed as unknown when using skipToken and TypeScript 5.4.5 #7496

@arnoud-dv

Description

@arnoud-dv

Describe the bug

Noticed this when I attempted to update TypeScript as a prerequisite to update the Angular adapter to Angular 18 as the type test failed.

Your minimal, reproducible example

https://www.typescriptlang.org/play/?ts=5.3.3#code/JYWwDg9gTgLgBAbzgVwM4FMCKz1QJ4A0KG2uw6qRqA1sGACoTXoB2cAvnAGZQQhwByAAIwAhi1RiAxtQD0UdKKkwAtAEcc+AQChtUiBPgbceAEoVkAGxio4AXmJZN5VAAoE2uHGNQXALjgAbU8vRBDQ7008AGl0PADAgQB3YBgACwBlWgYmVgEAXQJw0J88ADEWAIBZUXSAOihxABM+VwBKOAA+OAAGOoBWOAB+OBo6RmY2APb7boAFXhBgDAaKCEsAN3RXfraiiPZ9uELtdjbdWVk4JtrROGW4FmQQACNcOAAfFBYm9C5gFjoJpwFLpOD0PBgdAZKS+MDwfp1ADMyKIL2Q8GQLGoLAgSTYoLS4Mh0NhdARdQALAM9AZJNdbvZIiZzKgrDZAj18nUbmJtJcIl4AHpDXT6QzM-Cs9lMtBOEzuEKlWLxILJVKZbITPInLylCrVWppBrNVodbp9QYjMY5SZwaYdOzzRbLdCrVDrLY7Panc78q68u4PJ6vd5fLG-f6A4GEuAvCBgiFQmFwinUwbNOCIlFI2kSwMAJiZpWl1h5t39grgIu0QA

Steps to reproduce

On the TS playground:

Notice both data from useQueries and data2 from useQuery are correctly typed number | undefined.
Switch the TypeScript version to 5.4.5
Notice data from useQueries is now typed as unknown, data2 from useQuery is still correctly typed.

Expected behavior

useQueries data should not be typed as unknown

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Tanstack Query adapter

react-query

TanStack Query version

5.40.0

TypeScript version

5.4.5

Additional context

The Vue adapter has an equivalent type test which also fails, I suspect it's a problem for every framework.

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