Mohammed AnasM
tRPC3y 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
Was this page helpful?