Skip to content

Conversation

@weswigham
Copy link
Member

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



const enum Tag2 {}
declare function isNonBlank2(value: string) : value is (string & Tag2);
Copy link
Member

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?

Copy link
Member Author

@weswigham weswigham Jun 6, 2016

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)

@sandersn
Copy link
Member

sandersn commented Jun 6, 2016

👍

@sandersn
Copy link
Member

sandersn commented Jun 6, 2016

I'll merge since Wesley's still waiting on commit privileges.

@sandersn sandersn merged commit bfafecc into microsoft:master Jun 6, 2016
@sandersn sandersn deleted the refix-primitive-narrowing branch June 6, 2016 22:18
@zpdDG4gta8XKpMCd
Copy link

is this approved by @ahejlsberg, can i use it to build upon?

@sandersn
Copy link
Member

sandersn commented Jun 7, 2016

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.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants