Skip to content
Source
Sign inSign up
TanStack/query

Regression between 5.100.12 and 5.100.13 (useQuery's data being inferred as any) #11244

ClosedAlexis-D(GitHub profile, opens in a new tab) opened this issue 3 comments

Describe the bug

react-query 5.100.13 includes a single change, an update to query-core 5.100.13. Which in turn includes a single change. Which links to #9937, #10593.

I believe this introduces a regression as shown in https://github.com/Alexis-D/useQuery.

This code in 5.100.12:

https://github.com/Alexis-D/useQuery/blob/fd14f0eb61cb851dbb12cea99afcb9dd88ab44f0/with-5.100.12/src/App.tsx#L8-L13

Correctly infers data as Foo:

Image

But the same code with 5.100.13:

https://github.com/Alexis-D/useQuery/blob/fd14f0eb61cb851dbb12cea99afcb9dd88ab44f0/with-5.100.13/src/App.tsx#L8-L13

Infers data as any:

Image

Which looks like a regression?

Your minimal, reproducible example

https://github.com/Alexis-D/useQuery/tree/master

Steps to reproduce

  1. git clone git@github.com:Alexis-D/useQuery.git
  2. cd useQuery
  3. (cd with-5.100.12 && npm i) && (cd with-5.100.13 && npm i)
  4. Open with-5.100.12 and with-5.100.12 in your editor of choice, compare the infered types of data in src/App.tsx.

Expected behavior

data should be infered as Foo in both versions.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

macOS, though I'm guessing that's unrelated.

Tanstack Query adapter

react-query

TanStack Query version

v5.100.13

TypeScript version

v6.0..3

Additional context

No response

  1. I trust the TS playground more when it comes to type inference than the stackblitz container.

  2. TkDodo closed this

  3. Solved: for anyone having a similar issue, it boiled down to codium using the typescript version it bundles (which in my case was 5.3 which predates the introduction of NoInfer in 5.4), rather than the one specified in package.json. codium can be told to use the node_modules/typescript/lib version by setting typescript.tsdk in .vscode/settings.json and then:

    cmd+shift+p:

    Image Image

    tl;dr: no issues with react-query, just non-intuitive editor behavior. Sorry for the noise!

Sign in to join this conversation.