taylor.presto
taylor.presto14mo 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 Elsakaan14mo ago
its ctx.db not just db you didn’t use ctx at all
taylor.presto
taylor.prestoOP14mo ago
Neither work
taylor.presto
taylor.prestoOP14mo ago
No description
<DxD/>
<DxD/>14mo ago
What error do you have ? Or what is says ?
taylor.presto
taylor.prestoOP14mo 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/>
<DxD/>14mo ago
:))) I had this problem before

Did you find this page helpful?