How do i get ts to infer the proper type for exist...
# orm-help
d
How do i get ts to infer the proper type for existing?
Copy code
// type for existing gets inferred like this: 
// { id: string | null }[]
Copy code
const existing = prisma.users.findMany({
  select: { id: true },
  where: { NOT: { id: null } }
})
I tried to use Prisma validators with a validator for select and a seperate for where or one for the FindManyArgs type, but this didnt seem to work properly. How do I get the correct returnType of string ids in this case? Thanks guys 🙂
👀 1
n
Hey 👋 Could you have a look at this reference Guide? I think you are looking for this: Getting access to return type
d
Copy code
const validated = Prisma.validator<Prisma.UserFindManyArgs>()({
  select: {
    id: true,
  },
  where: {
    id: {
      not: null,
    },
  },
});

const existing = prisma.users.findMany(validated)
Hey 👋 So this still returns the type mentionaed above with the null and if i set them separately, it has the same result
the return function type thing it isnt working either. Is this a prisma bug? TSC caught this during nullChecks
v
@Davedavedave apologies for the delay in helping out with this problem, Nurul went on paternity leave, and unfortunately, I finished a monthly audit of unanswered questions only now! 😅 Have you perhaps already answered these questions or are you still looking for help?