Using enum values as strictly typed object keys

In TypeScript, it’s often useful to define interfaces or complex (structured) types whose properties (or keys) may only be values of a previously defined enum type. Here’s a good example: an object declaring a set of buttons for a modal dialog. Instead of this… type DialogButtons = { yes?: boolean, no?: boolean, cancel?: boolean } interface IDialog { buttons: DialogButtons } const dialog: IDialog = { buttons: { yes: true,

Continue reading