You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In other staticly-typed languages, this backing number is fine, since the type checker prevents these kinds of comparisons, but that is not the case in js. I mostly worry about switch statements -- if you switch on an enum with another enum or a number, it will appear to work. Not so with a symbol, which will always hit the default case.
The text was updated successfully, but these errors were encountered:
The value of enums for me is to surface API misuse by locking down the set of acceptable values in one definition - one source of truth.
So defaulting to Symbols would aid this use-case, because it prevents equivalent values being invented/duplicated in arbitrary parts of the code base that may get out of sync with the source of truth over time.
As currently proposed, default enums will have equal members. For instance:
In other staticly-typed languages, this backing number is fine, since the type checker prevents these kinds of comparisons, but that is not the case in js. I mostly worry about switch statements -- if you switch on an enum with another enum or a number, it will appear to work. Not so with a symbol, which will always hit the default case.
The text was updated successfully, but these errors were encountered: