I have the following type - export type Sizes = 'small' | 'medium' | 'big' and I want to use this type as keys for an object I'm creating:
type SizeInformation = {
[key in Sizes]: string;
}
However, the desired functionality here is that this type (and therefore the object that will be created based on it) doesn't necessarily need to have all keys named, or none at all, but if a key goes into the object, it should be of type Sizes.
As such, an empty object would be valid, an object with just the key medium would also be valid, but if an object has the keys medium and sea, it is not valid, as, again, all keys need to be of type Sizes.
I've played around with Partial but to no avail.
How can I achieve that? Thank you.
Partialshould work here.