henrikfiedler
henrikfiedler
DTDrizzle Team
Created by henrikfiedler on 6/25/2023 in #help
Infer Type from PgEnum
Hey, I'd like to infer a PgEnum to a TypeScript Type. So something like this:
const eventTypeEnum = pgEnum('event_type', [
'training',
'matchday',
'tournament',
'event',
'labour'
]);

// get the following as a result
type EventType = 'training' | 'matchday' | 'tournament' | 'event' | 'labour'
const eventTypeEnum = pgEnum('event_type', [
'training',
'matchday',
'tournament',
'event',
'labour'
]);

// get the following as a result
type EventType = 'training' | 'matchday' | 'tournament' | 'event' | 'labour'
How could I achieve this?
3 replies