I have a enum and I let each value of the enum as a key in my interface whose value is specific to the key.
Example:
enum Fruits {
Apple = "Apple",
Banana = "Banana",
}
// EDIT: These slicers can have completely different shapes.
interface AppleSlicer { foo: () => string }
interface BananaSlicer { bar: () => number }
interface FruitSlicers {
[Fruits.Apple]: AppleSlicer,
[Fruits.Banana]: BananSlicer,
}
This works well, but I want have similar code in several places and I want them to give me compile errors when there's a new entry in the enum. Currently, this doesn't do any exhaustive check, so it does not. Is it possible to achieve that with TypeScript?