I have an enum:
export enum PizzaSize {
SMALL = 0,
MEDIUM = 1,
LARGE = 2
}
But here I\'d like t
You can use a typed const to achieve this:
export const PizzaSize: {
[key: string]: { key: string, value: string };
} = {
SMALL: { key: 'key', value: 'value' }
};
Optionally you can extract the type information to separate interface declarations:
interface PizzaSizeEnumInstance {
key: string;
value: string;
}
interface PizzaSizeEnum {
[key: string]: PizzaSizeEnumInstance;
}
export const PizzaSize: PizzaSizeEnum = {
SMALL: { key: 'key', value: 'value' }
};