3 ms·
That precisely one of my problem with enum: almost all TS type is structural typing, why have this exception enums being nominal typing?
by forty 2y ago
That precisely one of my problem with enum: almost all TS type is structural typing, why have this exception enums being nominal typing?
- Tade0 2y agoAnd to add to the confusion Template Types let you compare enums as if they were strings.
- zdragnar 2y agoClasses aren't interchangable, excepting using a child when a parent is called for. Likewise, enums represent a discrete and unique set. The fact that there is either a number or a string used under the hood is irrelevant. I imagine using numbers or strings was useful for interop with vanilla JS (where JS needs to call a TS function with an enum as an argument), so it makes sense to use it instead of Symbols, which is what I typically pretend enumd are.