Generic type for Prisma ORM to be define output based on include
15:19 03 Dec 2025

I am writing a wrapper function for a model, but I want to make it as generic as possible. I intend to pass filters and includes as props, but this makes it harder to define the output accordingly.

For example:

async funciton getAllUser({filter?: Prisma.UserWhereInput, include?: Prisma.UserInclude}): Promise[]> {
  const users = await prisma.user.findMany({
    where: filter,
    include,

  return users;

This way I don't get any complaint from TS but when using this function the user returned does not have the correct type information

const allUsers = await getAllUser({ include: { posts: true }});
allUsers[0].posts // posts does not exists

So what I'm looking for is a way to relate the type of the include with the type that will be returned.

typescript prisma