Ever since TypeScript introduced unions types, I wonder if there is any reason to declare an enum type. Consider the following enum type declaration:
enum X
The enum type is not redundant, but in most cases union is preferred.
But not always. Using enums to represents e.g state transitions could be much more handy and expressive than using union**
Consider real live scenario:
enum OperationStatus {
NEW = 1,
PROCESSING = 2,
COMPLETED = 4
}
OperationStatus.PROCESSING > OperationStatus.NEW // true
OperationStatus.PROCESSING > OperationStatus.COMPLETED // false