Closed ArianHamdi closed 4 weeks ago
order matters:
order matters:
Actually destructuring in queryFn
is breaking inferring which I don't understand why this is happening.
also part of the typescript limitation. it's outlined in the reproduction in the linked issue.
Describe the bug
In
useInfiniteQuery
, thequeryFn
randomly infersunknown
instead of the actual data type.Your minimal, reproducible example
https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgVwM4FMCSA7AZsbYGdARWXSgE84BfOXKCEOAcgAEYBDbVLgYwDWAeijpOfGAFoAjuSosA3AFgAUKtXoAHpFhw+EHvDToAwmhhMAEhAgCAjHAC8cABQBKJwD5EquHFEwyFDYKBg4+ITEZBSULgi+fnCyMQDS6JQAXHAA2ix85kwsALoANAl+BETAnAA2AAqcAOboDVCcIFkADGUqiXDNMAByWjANza3tWS41nLxj6B6O3t3lcEJCBLgUKNgC2BAA7tiryVQAYthTSDSL3vG9ff7ogcE5diVwAEwfAMxFqzQen4bsoVDRQRptNB4PpDKFTAUQNZbJ8nK5bj4HgEgiFjOFKlE5LF7n1TpQ0pkcnlEcUgYkCdV6k0Wpw2h04CsHn4BsNNKNmRN2dNZvzmhjOX11qIQBAAG7oOAAE3QvCgyAkQXQq3Wm222GQIAARhRsv8uUkiRcphiSY9sa9su8vr8zX1AQkQapweoVFodDCDLx4WZeFYbAIfmj3F5MX57biwngCaQiXFtUIZfKLTELnALHmABYKixgdO6qBwfVGk2uxJkq2ua421Zx544t4fb5wP4Aul+MkUrK5fKhkC01YM2rzQVdPv9Z680UstlTGZzZnij1uUHgoA
Steps to reproduce
Hover over
queryFn
inuseCustomHook1
. The inferred type isunknown
, but it is inferred correctly inuseCustomHook2
anduseCustomHook3
.Expected behavior
It should always infer correctly.
How often does this bug happen?
Sometimes
Screenshots or Videos
Platform
Doesn't matter
Tanstack Query adapter
react-query
TanStack Query version
5.29.2
TypeScript version
5.4.5
Additional context
No response