tRPCttRPC
Powered by
brrB
tRPC•2y ago•
1 reply
brr

Trying to get the return type of a procedure.

Using TRPC v11. I am failing to return the type. I get the error
Type alias 'ProtectedProcedureType' circularly references itself.


Any ideas?
This is my code
type ProtectedProcedureType = inferProcedureBuilderResolverOptions<
  typeof protectedProcedure
>;

export type ProtectedProcedureContext = ProtectedProcedureType["ctx"];
type ProtectedProcedureType = inferProcedureBuilderResolverOptions<
  typeof protectedProcedure
>;

export type ProtectedProcedureContext = ProtectedProcedureType["ctx"];

I need the type to be reusable in other files.

I also tried this

type ProtectedProcedure = typeof protectedProcedure 
type ProtectedProcedureOptions = Parameters<Parameters<ProtectedProcedure['query']>[0]>[0]
export type ProtectedProcedureContext = ProtectedProcedureOptions['ctx']
type ProtectedProcedure = typeof protectedProcedure 
type ProtectedProcedureOptions = Parameters<Parameters<ProtectedProcedure['query']>[0]>[0]
export type ProtectedProcedureContext = ProtectedProcedureOptions['ctx']

still when I slap on the
export
export
I get the circularly references itself error...
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

Infer the type of ctx for a specific procedure
iDarkLightningIiDarkLightning / ❓-help
4y ago
return type of a query endpoint
rustclanRrustclan / ❓-help
3y ago