Why is this an issue?
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.
How to fix it
Either assign all enum members with values of the same type or none of them.
Code examples
Noncompliant code example
enum Color {
Red, // 0 by default
Green = 1,
Blue = "blue"
}
Compliant solution
enum Color {
Red = "red",
Green = "green",
Blue = "blue"
}
Noncompliant code example
enum Status {
SYN = 0,
SYN_ACK,
ACK = "ack"
}
Compliant solution
enum Direction {
SYN,
SYN_ACK,
ACK
}
Resources
Documentation