PrismaP
Prisma9mo ago
6 replies
skidy

Why do i get the wrong type

export type ForumPostType = Prisma.ForumGetPayload<{
  include: {
    // where: {
    //   id: string;
    // };
    author: {
      select: {
        name: true;
        username: true;
        image: true;
        likes:
          | {
              // where: { id: string };
              select: {
                id: true;
              };
            }
          | false;
        _count: {
          select: {
            likes: true;
          };
        };
      };
    };
  };
}>;

then i get this for likes field below, instead of | undefined or something. am i doing it wrong?
type ForumPostType = {
    author: {
        name: string;
        username: string | null;
        image: string | null;
        likes: {
            id: string;
            createdAt: Date;
            userId: string;
            forumId: string;
        }[];
        _count: {
            likes: number;
        };
    };
} & {
    id: string;
    ... 4 more ...;
    updatedAt: Date;
}
Was this page helpful?