Blitz
Blitz
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Blitz on 8/15/2023 in #questions
Need help with writing 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. Here is the full trace. been trying to make this work for so long now. im trying to build a TRPC reliant CMS
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; }>'
2 replies