T
TanStack2y ago
exotic-emerald

'lastPage' is of type 'unknown'.

How do I sovle this typing? I thought this should be typed automatically? Thanks in advance.
No description
7 Replies
exotic-emerald
exotic-emeraldOP2y ago
I just found that the data is also unknown :thinKING:
No description
exotic-emerald
exotic-emeraldOP2y ago
removing the arguments in queryFn fix the issue though
adverse-sapphire
adverse-sapphire2y ago
Put the queryFn first in the object. TypeScript inference is still a bit weird here I always do queryKey, then queryFn, then the rest
exotic-emerald
exotic-emeraldOP2y ago
Thank you. This fixes but bringing another typescript error
No description
exotic-emerald
exotic-emeraldOP2y ago
Types of property 'pageParam' are incompatible. Type 'string | undefined' is not assignable to type 'undefined'. Type 'string' is not assignable to type 'undefined'. When I change it to initialPageParam: '', it works Looks like I have to explicit typing the arguments in queryFn then?
adverse-sapphire
adverse-sapphire2y ago
Inference for pageParam happens from initialPageParam. If you put it to undefined, the type is likely just undefined
exotic-emerald
exotic-emeraldOP2y ago
I see. Thank you TkDodo 🙂 Really kind and helpful ❤️

Did you find this page helpful?