Best practice for using router types on client-side?

I saw that in T3s src/utils/trpc.ts we are provided with:
export type RouterInputs = inferRouterInputs<AppRouter>;
export type RouterOutputs = inferRouterOutputs<AppRouter>;
export type RouterInputs = inferRouterInputs<AppRouter>;
export type RouterOutputs = inferRouterOutputs<AppRouter>;
Can I effectively use this at the client-side like: const response: RouterOutputs['example']['hello'] or would that import a lot of unnecessary types at the client? Defining the types one by one and having to name them like: type HelloOutput = RouterOutputs['example']['hello'] is doable but annoying. Preferably I would like to avoid this step. Is that possible in a non-stupid way? 😄
1 Reply
cje
cje•2y ago
types don't exist at runtime so this is a non issue i usually don't even create named types from the inference helpers, just use them directly
Want results from more Discord servers?
Add your server