xenostar
xenostar
Explore posts from servers
TtRPC
Created by xenostar on 6/27/2023 in #❓-help
Strange trpc types
Hello, I just installed a fresh trpc project with prisma and next. I have a prisma schema such as:
model Example {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Example {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
and a router procedure like:
export const exampleRouter = createTRPCRouter({
getAll: publicProcedure.query(async ({ ctx }) => {
const values = await ctx.prisma.example.findMany();
return values;
}),
});
export const exampleRouter = createTRPCRouter({
getAll: publicProcedure.query(async ({ ctx }) => {
const values = await ctx.prisma.example.findMany();
return values;
}),
});
The issue is that the TS type if we hover the mouse over values is strange:
const values: Prisma.PrismaPromise<(GetResult<{
id: string;
createdAt: Date;
updatedAt: Date;
}, unknown> & {})[]>
const values: Prisma.PrismaPromise<(GetResult<{
id: string;
createdAt: Date;
updatedAt: Date;
}, unknown> & {})[]>
In the past it would have looked like:
const values: Example[]
const values: Example[]
Has anyone else noticed this behavior in their projects? Is this expected behavior? I noticed this in my personal project when I updated to the latest prisma packages. It may be related to 4.16.x versions of prisma. I was curious if others were having this issue?
2 replies
TTCTheo's Typesafe Cult
Created by xenostar on 6/27/2023 in #questions
Strange trpc types with latest create-t3-app example app
Hello, I just installed a fresh create-t3-app with prisma, tailwind, and trpc. If we navigate to the example getAll query in server/api/routers/example.ts, and modify it as such:
getAll: publicProcedure.query(async ({ ctx }) => {
const values = await ctx.prisma.example.findMany();
return values;
}),
getAll: publicProcedure.query(async ({ ctx }) => {
const values = await ctx.prisma.example.findMany();
return values;
}),
The issue is that the TS type if we hover the mouse over values is strange:
const values: Prisma.PrismaPromise<(GetResult<{
id: string;
createdAt: Date;
updatedAt: Date;
}, unknown> & {})[]>
const values: Prisma.PrismaPromise<(GetResult<{
id: string;
createdAt: Date;
updatedAt: Date;
}, unknown> & {})[]>
In the past it would have looked like:
const values: Example[]
const values: Example[]
Has anyone else noticed this behavior in their project? Is this expected behavior? I noticed this in my personal project when I updated to the latest prisma packages. So I created a fresh create-t3-app to see if it was happening there as well, and was able to verify it was. It seems to potentially be related to prisma 4.16.x versions.
12 replies