FluXF
tRPC10mo ago
2 replies
FluX

v11 types ProcedureBuilder & MiddlewareBuilder

You used to be able to import these types directly from @trpc/server. With v11 you can only import them via unstable-core-do-not-import.

I have some properties on a class that should hold a t.middleware and a t.procedure. What's the recommended way to type my Middleware and Procedure in v11?

type Middleware = ?
type Procedure = ?

const t = initTRPC.create()

class MyClass {
  private middleware: Middleware = t.middleware(({ next }) => next())
  private proc: Procedure = t.procedure

  public procedure(procedure: Procedure) {
    this.proc = procedure
    return this
  }

  public use(middleware: Middleware) {
    this.middleware = middleware
    return this
  }
Was this page helpful?