|
|
|
|
|
by eyelidlessness
1612 days ago
|
|
You can do that with an enum! enum Size {
small = 'small',
medium = 'medium',
large = 'large',
}
type ButtonProps = { size: Size.small | Size.medium }
And it’s still a nominal type in the union.Regarding likelihood of collision, it’s easy for me to imagine mixing up 'post' in an API call to a vendor for fence materials lol. In any case I find the added safety comforting, particularly over a language where interfaces tend to be exceedingly dynamic and flexible. |
|