prisma-tools icon indicating copy to clipboard operation
prisma-tools copied to clipboard

PrismaSelect - `Record<string, unknown> ` instead of `any`

Open baptistemarchand opened this issue 1 year ago • 0 comments

Hi,

It's easier to explain with an example :

  const select = new PrismaSelect(info).value
  // `foo` does not exist in my model so I want to have a TypeScript error here
  await prisma.user.findUnique({where: {id: '123', foo: 42}, ...select})

In the above code I don't get an error, even though the field foo does not exist in my model. That's because select is typed as any, so the spread of ...select makes the whole object any. If I change the first line to :

const select: Record<string, unknown> = new PrismaSelect(info).value

I get the error on foo as expected. So I suggest that new PrismaSelect(info).value should return Record<string, unknown> by default.

baptistemarchand avatar Oct 05 '23 09:10 baptistemarchand