Open oceandrama opened 1 year ago
@oceandrama I chose to add the Type
because if somehow you need to import the enum from prisma client
it would be named Role
. So to be able to distiguish between the enum and the type I chose to add Type
to the name. Maybe it would make more sense to name it something like RoleUnion
or RoleKeyUnion
?
@prisma/client
exports enum and its type with the same name:
export const Role: {
ADMIN: 'ADMIN',
USER: 'USER'
};
export type Role = (typeof Role)[keyof typeof Role]
So you can import only type from @prisma/client
too without zod-prisma-types
import type { Role } from "@prisma/client";
// or
import { type Role } from "@prisma/client";
Now, with
createModelTypes=true
it generates this for models:and this for enums:
and if you have enum like
SectionType
it generatesSectionTypeType
typeIt's look like the lack of consistency to add
Type
postfix for enums and not to add it to models. It's impossible to create enum and model with the same name insideschema.prisma
file, so there will be no name conflict after removing this postfix