Hey y'all! I'm wondering if someone could help me ...
# orm-help
t
Hey y'all! I'm wondering if someone could help me figure out how to properly type a function wrapping a prisma call in TypeScript. I have a function that looks something like this:
Copy code
export async function getUser(
  request: Request,
  { include }: { include?: Prisma.UserInclude } = {},
) {
  const session = await getUserSession(request)
  const userId = session.get(`userId`)

  if (!userId || typeof userId !== `string`) {
    return null
  }

  return db.user.findUnique({ where: { id: userId }, include })
}
Now, no matter what I do, calling
getUser(request, { include: { classes: true } })
does not get typed as
Promise<(User & { classes: Class[] }) | null>
. It gets typed as
Promise<(User & {}) | null>
. I can't figure out how to make it infer the return type properly based on the given
include
. Any help would be greatly appreciated!