Upsert seems to give me an error about returning type any?

Been reading through the create t3 app. Working to understand prisma, zod, and router. I created a Model like the following:
model Transcoder {
id String @id
name String
}
model Transcoder {
id String @id
name String
}
when attempting to create a router I do:
export const transcoderRouter = createTRPCRouter({
save: publicProcedure
.input(
z.object({
id: z.string(),
name: z.string()
})
)
.mutate(({ input, ctx }) => {
const { id } = input
return ctx.prisma.transcoder.upsert({
where: { id },
create: { id },
update: input
})
})
})
export const transcoderRouter = createTRPCRouter({
save: publicProcedure
.input(
z.object({
id: z.string(),
name: z.string()
})
)
.mutate(({ input, ctx }) => {
const { id } = input
return ctx.prisma.transcoder.upsert({
where: { id },
create: { id },
update: input
})
})
})
But VSCode is telling me:
Unsafe Return of any typed value.
I was thinking it would inherit a type of the model? I wasnt sure if it is related to me using typescript-eslint, BUT i didnt see other samples on the prisma website?
3 Replies
__fallenreaper
I been working on this throughout the night, but i still dont understand why Theos sample is properly returning a type, but this sample isnt. I did the prisma db push, and the npm build to see if that resolved things, but it didnt.
Scot
Scot2y ago
Is it just vscode giving you issues or does it fail to build
__fallenreaper
It is vscode giving me errors, so it doesnt recognize types. It does seem like it builds. I was thinking that maybe there is something wrong with my typescript-eslint, but i didnt see any flags in the create-t3 sample Example.ts file. So it seems to understand one but not the other is kinda weird, which is while it seems that the linter doesnt seem to understand it, why is it an isolated case.
Want results from more Discord servers?
Add your server