I am tring to have a map type with a Record in Typescript with the key in an Enum.
I have this Enum :
enum CatName {
miffy = "miffy",
boris = "boris",
mordred = "mordred",
}
And this Interface :
interface CatInfo {
age: number;
breed: string;
}
If I use this type :
type Cats = Record<CatName, CatInfo>
I must use all of the keys of the enum and that is not what I want.
If I use this type :
type Cats = Partial<Record<CatName, CatInfo>>
I can create a map with only some keys of the Enum as I want but CatInfo can be now undefined and I need it to be mandatory.
Is there a way to achieve a map with some keys but with a mandatory value ?
Here is a link to a playground if it can help.