taylor.presto
taylor.presto8mo ago

I am getting a errors after starting a TRPC project with T3. "Unsafe return of an `any` typed value"

It seems like something is off between Prisma and TRPC but I can't figure out why the type infrence isn'y working here. Anyone run in to this issue before?
import { z } from "zod";
import { db } from "~/server/db";
import {
createTRPCRouter,
protectedProcedure,
publicProcedure,
} from "~/server/api/trpc";

export const certificateRouter = createTRPCRouter({
create: publicProcedure
.input(
z.object({ name: z.string().min(1), description: z.string().min(1) }),
)
.mutation(async ({ ctx, input }) => {

// ERROR HERE: Unsafe assignment of an `any` value.
const certificate = await db.certificate.create({
select: {
id: true,
},
data: {
name: input.name,
description: input.description,
certificateId: "1",
organizationId: "1",
},
});

// ERROR HERE: Unsafe return of an `any` typed value.
return certificate;
}),
});
import { z } from "zod";
import { db } from "~/server/db";
import {
createTRPCRouter,
protectedProcedure,
publicProcedure,
} from "~/server/api/trpc";

export const certificateRouter = createTRPCRouter({
create: publicProcedure
.input(
z.object({ name: z.string().min(1), description: z.string().min(1) }),
)
.mutation(async ({ ctx, input }) => {

// ERROR HERE: Unsafe assignment of an `any` value.
const certificate = await db.certificate.create({
select: {
id: true,
},
data: {
name: input.name,
description: input.description,
certificateId: "1",
organizationId: "1",
},
});

// ERROR HERE: Unsafe return of an `any` typed value.
return certificate;
}),
});
No description
7 Replies
Ahmed Elsakaan
Ahmed Elsakaan8mo ago
its ctx.db not just db you didn’t use ctx at all
taylor.presto
taylor.presto8mo ago
Neither work
taylor.presto
taylor.presto8mo ago
No description
DxD
DxD8mo ago
What error do you have ? Or what is says ?
taylor.presto
taylor.presto8mo ago
Where I declare the const certificate I get Unsafe assignment of an any value. AND Where I return the const I get Unsafe return of an any typed value. Just had to restart vscode 🤦 - sorry guys!
DxD
DxD8mo ago
:))) I had this problem before