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.
Hi,
It's easier to explain with an example :
In the above code I don't get an error, even though the field
foo
does not exist in my model. That's becauseselect
is typed asany
, so the spread of...select
makes the whole objectany
. If I change the first line to :I get the error on
foo
as expected. So I suggest thatnew PrismaSelect(info).value
should returnRecord<string, unknown>
by default.