使用枚举类型或对象来避免使用布尔值扩展
示例代码:
// 不推荐的代码: type ButtonProps = { isActive: boolean; isDisabled: boolean; };
// 推荐的代码: enum ButtonStatus { ACTIVE = "active", DISABLED = "disabled", }
type ButtonProps = { status: ButtonStatus; };
// 或者推荐使用对象: type ButtonProps = { style: { backgroundColor: string; color: string; }, // ... };