-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add 'bitflags' modifier for enum. #42533
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
Add 'bitflags' modifier for enum. #42533
Conversation
@ShuiRuTian we were discussing allowing the modifier/tag/whatever in any mode, but only having it do anything different from normal enums today under a new flag - so you can opt in to strictly checking bitflagginess. This way it wouldn't be a straight break for anyone currently using normal enums as bitflags. |
@@ -9574,29 +9576,20 @@ namespace ts { | |||
if (links.declaredType) { | |||
return links.declaredType; | |||
} | |||
if (getEnumKind(symbol) === EnumKind.Literal) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is EnumKind on earth?
@weswigham Thanks a lot! the beta version is ready for review. But, I find something strange about the enums, which blocks me on It is basically about But at the same time, we could see in function Also, it seems if type is PS: I change a big else-if to
Reason: this helps debug, the code would jump to the first true condition, pass a lot false condition. |
The TypeScript team hasn't accepted the linked issue #42521. If you can get it accepted, this PR will have a better chance of being reviewed. |
Numeric is the old bitflag allowing enum, while |
This comment has been minimized.
This comment has been minimized.
Seems a new keyword is not acceptable. Would restart working on this if there is any new thought. |
To help with PR housekeeping, I'm going to close this draft PR. It is pretty old now. |
Fixes #42521
bitflags
.|
,|=
,&
,&=
,^
,^=
) is only allowed for bitflags enum, if left or right is enum.bitflags
check.The second one is a big break! Maybe it should be loosen, but how?
And I think there are more features could be added!
Some Questions:
bitEnum
bitflags
?bit
? Shouldbitflags
be a modifier or tag or something else?