taylor.presto
taylor.presto3y ago

How to infer the output of a mutation? The current methods appear to be depreciated.

I am attempting to export the bellow utility function to use client side to infer an output type that I can pass to a couple components that are consuming the data. It appears the the ''mutations' is depreciated here when trying to access it off the '_dep'? I did some digging the code base and that seems to be the case. Does anyone have advice on how to infer this type so I can pass it where it is needed?
export type inferMutationOutput<
TRouteKey extends keyof AppRouter['_def']['mutations']
> = inferProcedureOutput<AppRouter['_def']['mutations'][TRouteKey]>
export type inferMutationOutput<
TRouteKey extends keyof AppRouter['_def']['mutations']
> = inferProcedureOutput<AppRouter['_def']['mutations'][TRouteKey]>
2 Replies
Dani;
Dani;3y ago
Are you on trpc v10? If so, look at the new ways of inferring types: https://trpc.io/docs/v10/infer-types
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.
taylor.presto
taylor.prestoOP3y ago
Ahhhh I think that was it. I think someone updated the package on me and I missed it 🤦‍♂️ Thanks @Dani;

Did you find this page helpful?