-
Notifications
You must be signed in to change notification settings - Fork 12.8k
allow type narrowing with NonNullExpression #41075
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
@typescript-bot perf test this |
Heya @weswigham, I've started to run the perf test suite on this PR at 58781b0. You can monitor the build here. Update: The results are in! |
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.
Assuming the perf tests come back OK (always a good idea to check with control flow changes), this looks great to me.
@sandersn @ahejlsberg should this be 4.1 or 4.2 bound? |
I'd lean 4.2, but it's a small change so if the perf results come back clean, 4.1 would be OK too. |
If perf looks good I'm fine with having this in 4.1. |
@weswigham Here they are:Comparison Report - master..41075
System
Hosts
Scenarios
|
Happy hacktoberfest! 🎃🥳
Fixes #36958.
Example
Code
Current Behavior (TS 4.1 Beta)
New Behavior
(no errors)
Details & Discussion
This PR enables type narrowing when condition is a NonNullExpression.
The original issue includes following example, but this PR does not fix that case.
To fix this case, we have to take
expr > 0
and similar expressions into consideration, which I think is too complex compared to the outcome. How do you think?