Possible to infere type from PgEnum?

how to get the type of something like this export const serenity = pgEnum("serenity", ["ok", "warning", "critical", "error"])
1 Reply
oke
oke3w ago
how about
type Severity = (typeof pgEnum.enumValues)[number]
type Severity = (typeof pgEnum.enumValues)[number]
Maybe a more readable way is to define the array of values first, then pass that array into pgEnum
const severities = ["ok", "warning", "critical"] as const;
type Severity = typeof severities[number];
const severityPgEnum = pgEnum("severity", severities);
const severities = ["ok", "warning", "critical"] as const;
type Severity = typeof severities[number];
const severityPgEnum = pgEnum("severity", severities);
Want results from more Discord servers?
Add your server