Skip to content
Source
Sign inSign up
TanStack/query

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

Send to my agent
Closedarnoud-dv(GitHub profile, opens in a new tab) opened this issue 2 comments

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.

  1. arnoud-dv(GitHub profile, opens in a new tab) added labelspackage: react-query

  2. arnoud-dv(GitHub profile, opens in a new tab) added labelspackage: vue-query

  3. TkDodo added labelsbug

  4. TkDodo added labelstypes

  5. Yeah seems like we need to take a look at the useQueries types which are super complex :/

  6. The playground does not show the bug anymore since the useQueries type inference was improved 🎉 Thank you @gwansikk

  7. TkDodo closed this

Sign in to join this conversation.