Was hoping this might produce a compile time error but I guess I have just misunderstood how enums work...
enum SortDirection {
ascending = 1,
descending = -1
}
type IndexSpec = {[index: string]: SortDirection};
var i: IndexSpec = {thing: 3}; // no compile time error
All numeric values are considered value enum values.
This is allowed because there's no distinction between flag and non-flag enums:
enum MyFlags {
Cool = 0x1,
Awesome = 0x2,
Neat = 0x4
}
var i: MyFlags = 5; // Cool | Neat
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With