'lastPage' is of type 'unknown'.
How do I sovle this typing? I thought this should be typed automatically?
Thanks in advance.

7 Replies
exotic-emeraldOP•2y ago
I just found that the data is also unknown :thinKING:

exotic-emeraldOP•2y ago
removing the arguments in
queryFn
fix the issue thoughadverse-sapphire•2y 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-emeraldOP•2y ago
Thank you. This fixes but bringing another typescript error

exotic-emeraldOP•2y 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•2y ago
Inference for pageParam happens from initialPageParam. If you put it to undefined, the type is likely just
undefined
exotic-emeraldOP•2y ago
I see. Thank you TkDodo 🙂 Really kind and helpful ❤️