-
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
instanceof should error when all constituents of a union are primitives #18519
Labels
Milestone
Comments
That's not always the expected behavior. When targeting a runtime with class PrimitiveNumber {
static [Symbol.hasInstance](x) {
return typeof x === 'number';
}
}
console.log(123 instanceof PrimitiveNumber); // true |
Sure, but
|
Wouldn't an appropriate behavior then be to issue an error unless the value on the right hand side has a |
PR #19063 opened to resolve this issue. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Expected:
Actual:
No error, incorrect narrowing behavior (#14426)
Edit: Corrected the example to actually be a union.
The text was updated successfully, but these errors were encountered: