-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
number & { __brand } is not working with the comparison operator in nightly build #11643
Comments
The error first appeared in a63a0d8. |
Hey Aleksey, This ties into an ongoing discussion about what we think about the use/addition of nominal types in our type system. There is a long list of issues related to nominal types. It looks like this feature is actually working as designed, though the behavior is admittedly a bit counter-intuitive at first glance. Based on the recent addition of the comparability relation (issue #5517), specifically here, x isn't comparable to '0' because '0' is a numeric literal, and thus a subtype of 'number'. Here are two workarounds (inspired by your comment here :) ):
In fact, this should be a general solution for dealing with "nominal typing" via brands: upcasting the other argument to a comparison operation to that of the two types' common ancestor will make the comparison pass our type check. |
interesting, i will consider that |
The text was updated successfully, but these errors were encountered: