sirisian / ecmascript-types

ECMAScript Optional Static Typing Proposal http://sirisian.github.io/ecmascript-types/
453 stars 4 forks source link

Non-numeric enumerations and their errors #24

Closed sirisian closed 5 years ago

sirisian commented 7 years ago

An enumeration that uses a string value type must define a starting value which is not incremented. As defined before a custom sequential function would be expected:

// enum Count:string { Zero, One, Two }; // TypeError Zero is undefined
enum Count:string { Zero = `0`, One, Two }; // One and Two are also `0`.

bool, string, object, SIMD, rational, and complex would all follow these same rules.

Can symbol be used as an enum type?

sirisian commented 5 years ago

Added: https://github.com/sirisian/ecmascript-types#enum-type

Also symbol can be used as an enum type.