-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Cannot use the enum[member]
notation in types
#46473
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
This is working as intended - that syntax is an indexed access type. If you want to grab the type of |
Also, to be explicit, #19707 discusses this further. |
I don't understand how that is intended, or why |
Because Also, |
@fatcerberus I'm not sure what you're trying to say, directly accessing properties Please explain why |
let x: CharCode = CharCode.a;
console.log(x["("]); // type error You now have a number value stored in As for your last question: |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
🕗 Version & Regression Information
ts stable & nightly
⏯ Playground Link
Playground Link
💻 Code
🙁 Actual behavior
The
enum[member]
notation does not work in types, rendering members that are not valid identifiers inaccessible.Using
typeof
is required to make it work.🙂 Expected behavior
The
enum[member]
notation works in types.The text was updated successfully, but these errors were encountered: