Varich
Varich3y ago

save return type to type var

Hello, I want to save the type that return from useQuery to type variable. For example, I have this complex return type from the query and would like to do something like type userInfoType = object. Please point me to some direction. Thank youuuuu ❤️
5 Replies
Alex / KATT 🐱
Inferring Types | tRPC
It is often useful to wrap functionality of your @trpc/client or @trpc/react api within other functions. For this purpose, it's necessary to be able to infer input types, output types, and api paths generated by your @trpc/server router.
Varich
VarichOP3y ago
Thank youu
Varich
VarichOP3y ago
I have a follow-up question. So I follow your approach, but cannot denested the type and got the following type error. Any recommendation?
Alex / KATT 🐱
Maybe you need to wrap the preceding type with NonNullable
Varich
VarichOP3y ago
That save it. Thanks alex