I am dealing with an API that has the ability to return one of these options:
{ fill: 'string'}
or {stroke: 'string'}
or {effect: 'string'}
The key type I have established is as follows:
type StyleKeyType =
| 'fill'
| 'stroke'
| 'effect';
Now, in order to create a type for the object, I attempted the following:
type StylesObject = { [K in StyleKeyType]?: string };
However, this approach fails because it considers {}
as valid when it should not be in my scenario.
Is there a method to generate this type without having to manually list out each possible object type?