tRPCttRPC
Powered by
HussamH
tRPC•3y ago•
5 replies
Hussam

How to infer types of a query

Coinsider the example
const hello = trpc.hello.useQuery();
const hello = trpc.hello.useQuery();

I would like to export the type we get on hover(on hello).


I could only find how to infer the data type from the docs
const { data } = trpc.hello.useQuery()
const { data } = trpc.hello.useQuery()

https://trpc.io/docs/infer-types using
inferRouterOutputs
inferRouterOutputs


The reason I am passing everything and not just data as props down to components, is because I want to access the loading, error states etc.
Inferring Types | tRPC
It is often useful to wrap functionality of your @trpc/client or @trpc/react-query api within other functions. For this purpose, it's necessary to be able to infer input types and output types generated by your @trpc/server router.
Inferring Types | tRPC
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to infer query types on client?
MadMaxMMadMax / ❓-help
3y ago
How to infer types from input?
PieterPPieter / ❓-help
3y ago
Infer query type of `data`
bill92Bbill92 / ❓-help
2y ago