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
}
}

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])
}
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.
No description
3 Replies
Chris Valentine
Chris Valentine•4w ago
sigh i forgot to add await. i'm leaving this here for other people who have brain dead moments.
Yetzederixx
Yetzederixx•4w ago
Don't worry, I lost 3h of my life to scoping in js today
Chris Valentine
Chris Valentine•4w ago
i can relate 🙂
Want results from more Discord servers?
Add your server