rapini icon indicating copy to clipboard operation
rapini copied to clipboard

Export union types as objects

Open ghandic opened this issue 1 year ago • 1 comments

When generating enums, it would be good to centralise the options for use in select menus etc

When enums are produced at the moment it creates:

export type Payment = 'Debit' | 'Credit';

Preferentially it could be

export enum Payment {
    Debit = 'Debit',
    Credit = 'Credit'
}

Now you can access array of options:

Object.values(Payment)

ghandic avatar Oct 08 '22 06:10 ghandic

Alternatively define the array of enumerated values and then define the type from that, then it will avoid the typescript enum issues

ghandic avatar Jan 08 '23 01:01 ghandic