Sting Alleman
07/31/2021, 10:12 PMasync getUser(
userId: string,
conf?: { include?: Prisma.UserInclude; select?: Prisma.UserSelect }
): Promise<User> {
return await this.prisma.user.findUnique({
where: { id: userId },
...conf
});
}
Now, If I do, for example, getUser("id", {include: { posts: true })
, the return type of getUser will be wrong, because it doesn't include the posts relation.
I can fix this using generics, but that would mean that I also always have to add the User
generic. Is there another, better way to fix these return types?