I want to type an object which can only have keys 'a', 'b' or 'c'.
So I can do it as follows:
Interface IList {
a?: string;
b?: string;
c?: string;
}
They are all optional!
Now I was wondering if this can be written with Record
in just one line
type List = Record<'a' | 'b' | 'c', string>;
The only issue is that all keys need to be defined. So I ended up with
type List = Partial<Record<'a' | 'b' | 'c', string>>;
This works, but I can imagine there is a better way to do this without Partial. Is there an other way to make the keys optional inside Record ?