PrismaP
Prisma4mo ago
6 replies
Nisharg Shah

Why I am getting typescript type error in my findOne function

export interface RoleService {
  findOne: <S extends NonNullable<RoleFindFirstArgs['select']>>(
    params: RequireAtLeastOne<Omit<NonNullable<RoleFindFirstArgs['where']>, 'type'>>,
    select: S,
  ) => Promise<Pick<RoleSchema, keyof S> | null>;
}


const findOne: RoleService['findOne'] = async (params, select) => {
  const data = await prismaClient.role.findFirst({
    where: {
      ...params,
      type: {
        in: userTypesOfNoDefaults,
      },
    },
    select,
  });

  return data;
};


Getting error in two places, in keyof S and in findOne function, but if I am doing same thing in other project its working fine but not in Prisma, am I doing wrong?
Was this page helpful?