-
Notifications
You must be signed in to change notification settings - Fork 12.8k
get array from const enum #38960
New issue
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
Comments
const enum gender{ |
Duplicate of #21391. |
I am pretty sure he meant to allow some syntax that like const enum which is replaced with literal strings at runtime will be replaced with the literal array of the const enum options. const enum Test {
A = 'a',
B = 'b'
}
const values = valueof Test; It will get compiled to |
Yes. Please implement it. |
This would be type-directed emit, which is unlikely to be implemented. See point 5 at https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals#non-goals:
|
@fatcerberus Which means const enum goes against it too... I believe its just an enhancement to the already existing functionality |
To expedite the triage process, we need everyone to follow the issue template and instructions. When you clicked "Create New Issue", the issue form was pre-populated with a template and some instructions. We need you to read those instructions completely, follow them, and then fill in all the fields in that template. We are not able to assist with issues that don't follow the template instructions as they represent a significantly larger amount of work compared to issues which are correctly specified. Thank you for understanding. |
every we can use them like:
compiles to
then it is logical to have also a way to access the whole group of values. |
I hope there is a way to get an array from const enum.
for example:
const enum gender{
male = 1,
female = 2,
}
I need to there is a way to get an array from the const enum gender, and the result like this:
[1,2]
Thanks a lot!
The text was updated successfully, but these errors were encountered: