t
tRPC
H
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
.
tRPC
Join
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Recent Announcements
Similar Threads
How to infer query types on client?
M
MadMax / ❓-help
3y ago
How to infer types from input?
P
Pieter / ❓-help
3y ago
Infer query type of `data`
B
bill92 / ❓-help
2y ago