-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Type guard intersection types #9031
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
Conversation
|
||
// All winged beasts with legs | ||
if (hasWings(beast)) { | ||
if (beast.legs === 4) { // ERROR TS2339: Property 'legs' does not exist on type 'Winged'. |
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.
comments are misleading now.
👍 |
} | ||
} | ||
|
||
// Repro from #9011 |
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.
should be #9016
This is a really great enhancement to type guards. |
IMO this is a major improvement to control flow based type inference that should probably be mentioned in the roadmap and in the upcoming 'what's new in TypeScript' for 2.0. |
Fixes #8911.