© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
5 replies
Rph

Get plain typescript type from enum

Hi,
I am working on a NestJS + Drizzle app and I have the following in my schema:
export const userPermissionLevel = pgEnum("permissionLevel", ["admin","moderator","user","banned"]);
export const userPermissionLevel = pgEnum("permissionLevel", ["admin","moderator","user","banned"]);


Elsewhere in my code, I am writing a NestJS service that aims to resolve a user based on their current session cookie and I'd like to return the following type:
export interface UserMetadata {
        hasEmail: boolean,
        permissions: ???,
        username: string
}
export interface UserMetadata {
        hasEmail: boolean,
        permissions: ???,
        username: string
}


Is there a way to somehow make the
permissions
permissions
field always have a type in sync with the pgEnum? I tried InferColumnType but that clearly isn't correct

Ideally in this scenario, I'd have
permissions
permissions
be the following type:
"admin"|"moderator"|"user"|"banned"
"admin"|"moderator"|"user"|"banned"
but of course derived somehow from the original enum declaration
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Is there a simpler way to get an enum type than (typeof enumType)["enumValues"][number]?
Drizzle TeamDTDrizzle Team / help
3y ago
PGEnum -> Typescript Enum
Drizzle TeamDTDrizzle Team / help
3y ago
Any easy way to create a typescript ENUM type from pgEnum?
Drizzle TeamDTDrizzle Team / help
3y ago
Enum Type Creation
Drizzle TeamDTDrizzle Team / help
15mo ago