PrismaP
Prisma16mo ago
3 replies
Chris Valentine

Property does not exist on type..but it clearly does.

   
const lastIdResult = prisma.descriptionDiff.findFirst({
        where: {
            packageId: thisPackage.id
        },
        orderBy: {
            createdAt: 'desc'
        }
    });

    // need to check if this result is null or not
    if (lastIdResult) {
        if (lastIdResult.id === thisPackage.last_diff_id) {
            return false
        } 
    }


The model:
model DescriptionDiff {
  id       String @id @default(cuid())
  changes  Json   // Stores the entire diff result as a JSON object
  createdAt DateTime @default(now())
  packageId String
  package   FVTTPackage @relation(fields: [packageId], references: [id])
}


in the inner if statement i am getting a typescript error. Property 'id' does not exist on type (see screenshot)

It does exist, the hover over shows it exists. I'm so confused

i've upgraded typescript, restarted it, re-generated prisma client, reinstalled all node modules, restarted vs code, restarted computer. tried to cast (lastIdResult as DescriptionDiff).id

none of it works, keeps telling me it does not exist, while showing me that it does.

Any help is appreciated.
image.png
Was this page helpful?