Skip to content

no-boolean

Id
@azure-tools/typespec-azure-core/no-boolean

Boolean properties should use descriptive extensible enums when semantic values matter.

Boolean values can be hard for API users to understand when the property or payload represents a domain state, option, or mode. Prefer a descriptive extensible enum modeled as a union so future values can be added without a breaking change.

  • Area: SDK, API

Boolean shapes can make generated clients less readable and can force future breaking changes if the API later needs more than two values.

This rule corresponds to the LintDiff rule EnumInsteadOfBoolean.

model Widget {
enabled: boolean;
}
@get
op isWidgetEnabled(): boolean;
union WidgetState {
Enabled: "Enabled",
Disabled: "Disabled",
string,
}
model Widget {
state: WidgetState;
}
@get
op getWidgetState(): WidgetState;

Suppress this rule only when the value is inherently boolean and is unlikely to grow additional states, such as a simple yes/no capability.