I have two enums that are constructed on each other in the following way:
enum COLOR {
White = '#FFFFFF',
Black = '#000000',
SuccessStatusForeground = '#57A300',
ErrorStatusForeground = '#E00B1C',
}
export enum SemanticColor {
Default = COLOR.Black,
DefaultBackground = COLOR.White,
Success = COLOR.SuccessStatusForeground,
Error = COLOR.ErrorStatusForeground,
}
When I try to pass a style object using { backgroundColor: SemanticColor.Success }
I get:
Types of property 'backgroundColor' are incompatible.
Type 'SemanticColor' is not assignable to type 'string | undefined'
It looks like TypeScript isn't able to infer that the enum's value is in fact a string. Any ideas how to solve this one?