Blitz
Blitz12mo ago

Need help with type hinting a function that accepts a trpc client router

interface CreateModelProps<GetResult> {
name: string,
procedures: DecoratedProcedureRecord<{
read: BuildProcedure<"query", any, any>
create: BuildProcedure<"mutation", any, any>,
update: BuildProcedure<"mutation", any, any>,
delete: BuildProcedure<"mutation", any, any>,
}, any>,
}
interface CreateModelProps<GetResult> {
name: string,
procedures: DecoratedProcedureRecord<{
read: BuildProcedure<"query", any, any>
create: BuildProcedure<"mutation", any, any>,
update: BuildProcedure<"mutation", any, any>,
delete: BuildProcedure<"mutation", any, any>,
}, any>,
}
got this so far, but a router with all these routes defined raises a veryyy long type error. so im assuming im doing something very wrong. Anyway, here is the full trace
Type 'DecoratedProcedureRecord<{ hello: BuildProcedure<"query", { _config: RootConfig<{ ctx: { session: Session | null; prisma: PrismaClient<PrismaClientOptions, never, DefaultArgs>; }; meta: object; errorShape: { ...; }; transformer: typeof SuperJSON; }>; ... 5 more ...; _output_out: unique symbol; }, { ...; }>; getAll: ...' is missing the following properties from type 'DecoratedProcedureRecord<{ read: BuildProcedure<"query", any, any>; create: BuildProcedure<"mutation", any, any>; update: BuildProcedure<"mutation", any, any>; delete: BuildProcedure<...>; }, any, "">': read, create, update, deletets(2739)
models.tsx(155, 5): The expected type comes from property 'procedures' which is declared here on type 'CreateModelProps<{ tags: { id: string; name: string; }[]; } & { id: string; name: string; content: string; }>'
Type 'DecoratedProcedureRecord<{ hello: BuildProcedure<"query", { _config: RootConfig<{ ctx: { session: Session | null; prisma: PrismaClient<PrismaClientOptions, never, DefaultArgs>; }; meta: object; errorShape: { ...; }; transformer: typeof SuperJSON; }>; ... 5 more ...; _output_out: unique symbol; }, { ...; }>; getAll: ...' is missing the following properties from type 'DecoratedProcedureRecord<{ read: BuildProcedure<"query", any, any>; create: BuildProcedure<"mutation", any, any>; update: BuildProcedure<"mutation", any, any>; delete: BuildProcedure<...>; }, any, "">': read, create, update, deletets(2739)
models.tsx(155, 5): The expected type comes from property 'procedures' which is declared here on type 'CreateModelProps<{ tags: { id: string; name: string; }[]; } & { id: string; name: string; content: string; }>'
0 Replies
No replies yetBe the first to reply to this messageJoin