Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrismaSelect - Record<string, unknown> instead of any #316

Open
baptistemarchand opened this issue Oct 5, 2023 · 0 comments
Open

PrismaSelect - Record<string, unknown> instead of any #316

baptistemarchand opened this issue Oct 5, 2023 · 0 comments

Comments

@baptistemarchand
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant