TypeScript provides both numeric and string-based enums. Members of enums can be assigned strings, numbers, both, or none, which default to numbers starting from zero. Although it is possble to mix the types of enum member values, it is generally considered confusing and a bad practice.
Enum members should be consistently assigned values of the same type, that is, strings or numbers.
Either assign all enum members with values of the same type or none of them.
enum Color {
Red, // 0 by default
Green = 1,
Blue = "blue"
}
enum Color {
Red = "red",
Green = "green",
Blue = "blue"
}
enum Status {
SYN = 0,
SYN_ACK,
ACK = "ack"
}
enum Direction {
SYN,
SYN_ACK,
ACK
}