3 ms·
Isn't Record<EnumType, whatever> working? Then instantiate like: ``` { [EnumType.First]: ..., [EnumType.Second]: ... } ```
by 5Qn8mNbc2FNCiVV 4y ago
Isn't Record<EnumType, whatever> working?
Then instantiate like:
```
{
[EnumType.First]: ...,
[EnumType.Second]: ...
}
```
- hn_throwaway_99 4y agoYep, do this all the time. It's also really nice because when you define a type as Record<EnumType, any> then when you are creating an instance of that Record object, it requires a key for all the EnumType values, and will fail if you forgot one. Still possible to do Partial<Record<EnumType, any>> if you want the keys to be only of the EnumType, but don't require all the EnumType values to be used as a key in the Record.