David Ilizarov
10/13/2022, 11:28 PMlet details: JsonValue | Prisma.DbNull = Prisma.DbNull;
// object.details is JsonValue
object.details = details === Prisma.DbNull ? null : details;
// Error: Type 'JsonValue | DbNull' is not assignable to type 'JsonValue'.
// Type 'DbNull' is not assignable to type 'JsonValue'
I don't see Prisma acknowledging this in documentation anywhere.
object.details = details instanceof Prisma.NullTypes.DbNull ? null : details;
// This works ^^^
Not sure I like the version that works for TypeScript. Thoughts?Vladi Stevanovic
JsonNull
in this case
Any comments/opinions from the Community, while I investigate are welcome! 😊Vladi Stevanovic
4.0.0
import { PrismaClient, Prisma } from ".prisma/client"
let detail: Prisma.JsonValue | typeof Prisma.DbNull = Prisma.DbNull
let detail2: Prisma.JsonValue
detail2 = detail === Prisma.DbNull ? null : detail
After 4.0.0
, instanceof
is the way to go:
import { PrismaClient, Prisma } from ".prisma/client"
let detail: Prisma.JsonValue | typeof Prisma.DbNull = Prisma.DbNull
let detail2: Prisma.JsonValue
detail2 = detail instanceof Prisma.DbNull ? null : detail
Vladi Stevanovic
David Ilizarov
10/15/2022, 6:41 AMVladi Stevanovic