-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Should treat const and enum (at least const enum) value the same as literals for indexers. #3411
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
Presumably your example intended to index into |
So can I take that as "this suggestion is reasonable"? :D |
Summary: When we see a property access where the indexing expression is an enum member, we should resolve the property access as if the indexing expression were actually the computed value of the enum member's value. In other words, |
And also consts, I think. |
Added a patch for the const enum access. Would also like to see these work:
The last 3 could work but require better tracking of constants and constant propagation like @danquirk mentioned. Don't think you need flow control to do it properly, have gotten it working without anyways. |
Approved for |
@jbondc, we would appreciate it if you can keep it only for const enums, and not for generic constant propagation. |
thanks @jbondc! |
This should also apply to something like tuples directly written as
[TypeA, TypeB, ...]
.The text was updated successfully, but these errors were encountered: