I have the following enum plus function that switch-case on it.
const enum ApplianceStatus {
ONLINE = "Online",
OFFLINE = "Offline",
UNAVAILABLE = "Unavailable",
}
function getStatusColor(status: ApplianceStatus) : string {
switch (status) {
case status.ONLINE:
return "list-group-item-success";
case status.OFFLINE:
return "list-group-item-danger";
case status.UNAVAILABLE:
return "list-group-item-warning";
}
}
I'm getting a Property '***' does not exist on type 'ApplianceStatus'.
The same exact pattern for this other enum works instead:
const enum SupportedColor {
BLUE = "Blue",
YELLOW = "Yellow",
}
// no error here
function doSomething(supportedColor: SupportedColor): boolean {
switch (supportedColor) {
case SupportedColor.BLUE:
return true;
case SupportedColor.YELLOW:
return true;
}
}
I really can't understand what's going on.