Closed ricayanzon closed 1 year ago
I need this feature. I can't get the correct type that is generated by Prisma inclusion and Prisma class generator Here is my example:
class UserDto extends IntersectionType(
PrismaModel.User,
PickType(PrismaModel.UserRelations, ['address','documents']),
)
implements
Prisma.UserGetPayload<{
include: typeof UserDto.include;
}>{
static get include() {
return Prisma.validator<Prisma.UserInclude>()({
address: true,
documents: true,
})
}
}
When address
field in UserGetPayload
is null, a type error occurs because undefined values generated by the library are not assignable to the type.
[EDIT] I wrote a solution locally, tested it and it worked. Can I request a PR?
fixed by #50
Thanks! But it seems that the npm package is behind the current version here - can you publish the new version in npm please? @kimjbstar
Expected Behavior
When a model inside the Prisma schema has a field that is defined as nullable (marked with the
?
, that field inside the generated class should also be nullable.Actual Behavior
The generator marks these nullable fields as optional (can be
undefined
) instead of nullable.Steps to Reproduce the Problem
model Foo { bar String? }
npx prisma generate
export class Foo { bar?: string }
and I'd expect it to beexport class Foo { bar: string | null }
Is this just me or what's the idea behind this?