Vinnie
Infer context from procedure after middleware
I'm using trpc version 10 on pnpm.
I I have my handler functions in separate files from the routers themselves.
I'm looking to type the context correctly based on the procedure the handler is used with.
Currently I am setting the
ctx
type from the Context
type that is inferred from the createContext
function.
The context type should rather be inferred from the privateProcedure
so the changes which are made to the context in middlewares will also be correctly typed.
I did see the inferProcedureBuilderResolverOptions
helper type, but it is only available in version 11, and version 11 hasn't been released yet. Is there a way to do this in v10?
https://trpc.io/docs/server/procedures#inferProcedureBuilderResolverOptions4 replies