-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Fix primitive narrowing #8993
Fix primitive narrowing #8993
Conversation
…ow-all-types"" This reverts commit fc3e040.
|
||
|
||
const enum Tag2 {} | ||
declare function isNonBlank2(value: string) : value is (string & Tag2); |
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.
how is string & Tag2 structurally different from just string?
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.
Tag2 is a const enum (making the intersection nominal)
👍 |
I'll merge since Wesley's still waiting on commit privileges. |
is this approved by @ahejlsberg, can i use it to build upon? |
Yes, it turns out there's not much perf hit from this change. However, narrowing will not expand beyond this to methods. That's the performance cliff that @ahejlsberg was thinking of. |
Fixes #7224.
Fixes #7441.
This is a re-submission of #7235 without the inversion of the type flag - meaning it simply adds all primitive types and intersection types to the narrowable types list.
@ahejlsberg @sandersn