We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"new enumeration type", "new enum", "enum key value"
I expect there to be a new enumeration type where the value of the enumeration type is equal to the key of the enumeration,
When I define an enumeration so that the key and value are the same string, I need to write as follows:
enum Action { EDIT = 'EDIT', ADD= 'ADD', DELETE = 'DELETE', }
This way a lot of redundant code is written.
enumStr Action { EDIT, ADD, DELETE, } console.log(Action.EDIT === 'EDIT') // true console.log(Action.ADD === 'ADD') // true console.log(Action.DELETE === 'DELETE') // true console.log(Action.EDIT === 0) // false console.log(typeof Action.EDIT) // string console.log(typeof Action.ADD) // string console.log(typeof Action.DELETE) // string
A new keyword enumStr is used here to define an enumeration. The key and value of the enumeration are the same string.
enumStr
to
enumStr Action { EDIT, ADD, DELETE, }
The text was updated successfully, but these errors were encountered:
Duplicate of #16464. Used search terms: enum string in:title
enum string in:title
Sorry, something went wrong.
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
🔍 Search Terms
"new enumeration type", "new enum", "enum key value"
✅ Viability Checklist
⭐ Suggestion
I expect there to be a new enumeration type where the value of the enumeration type is equal to the key of the enumeration,
📃 Motivating Example
When I define an enumeration so that the key and value are the same string, I need to write as follows:
This way a lot of redundant code is written.
I expect there to be a new enumeration type where the value of the enumeration type is equal to the key of the enumeration,
A new keyword
enumStr
is used here to define an enumeration. The key and value of the enumeration are the same string.💻 Use Cases
answer: Simplified syntax,Keep the original enum syntax unchanged,from
to
answer: I need to repeat a literal for key and value
The text was updated successfully, but these errors were encountered: