tRPCttRPC
Powered by
Mohammed AnasM
tRPC•3y ago•
7 replies
Mohammed Anas

How does trpc typing work

I'm curious to know how trpc generates type without a code gen step , i am trying to acheive something like this

export class API {
  private schema:z.ZodSchema = z.undefined()
  input<T>(inp:z.ZodSchema<T>){
    this.schema = inp
    return this
  }
  get(input:z.infer<typeof this.schema>){
    console.log(("ok"));
  }
}
const api = new API()
api.input(z.object({
  name:z.string()
}))

// I need a way to typically extract this {name:string} type without a codegen step
export class API {
  private schema:z.ZodSchema = z.undefined()
  input<T>(inp:z.ZodSchema<T>){
    this.schema = inp
    return this
  }
  get(input:z.infer<typeof this.schema>){
    console.log(("ok"));
  }
}
const api = new API()
api.input(z.object({
  name:z.string()
}))

// I need a way to typically extract this {name:string} type without a codegen step
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

How does tRPC work?
aspizuAaspizu / ❓-help
2y ago
Typing on trpc.createClient?
hashwarpHhashwarp / ❓-help
17mo ago
Why webhooks does not work with TRPC?
kstulgysKkstulgys / ❓-help
3y ago