Regression between 5.100.12 and 5.100.13 (useQuery's data being inferred as any) #11244
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:
Correctly infers data as Foo:
But the same code with 5.100.13:
Infers data as any:
Which looks like a regression?
Your minimal, reproducible example#
https://github.com/Alexis-D/useQuery/tree/master
Steps to reproduce#
git clone git@github.com:Alexis-D/useQuery.gitcd useQuery(cd with-5.100.12 && npm i) && (cd with-5.100.13 && npm i)- Open
with-5.100.12andwith-5.100.12in your editor of choice, compare the infered types ofdatainsrc/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
I trust the TS playground more when it comes to type inference than the stackblitz container.
TkDodo closed this
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
NoInferin 5.4), rather than the one specified inpackage.json. codium can be told to use thenode_modules/typescript/libversion by settingtypescript.tsdkin.vscode/settings.jsonand then:cmd+shift+p:
tl;dr: no issues with react-query, just non-intuitive editor behavior. Sorry for the noise!
Sign in to join this conversation.
this code looks fine in a typescript playground:
https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgVwM4FMCKz1QJ5wC+cAZlBCHAOQACMAhgHaoMDGA1gPRTr2swBaAI458VANwBYAFAzgjGLhJ90cAGIQIiGXDgAPAFxxGyEACNcU6YRkzWEZvACCYMHAC8cABQBKDwD5taV17R0QAE3oGYk80LFE8LwQdXThOTlSAPQB+FN0RXDwAaXQ8IwBtKnZSqgBdABo8uAL8NUYjXyMNLXdApP0jAGYiHxTCHytCKxl0PUhYOHD0ZWQAG2dXcSA