Repository navigation
allow type narrowing with NonNullExpression - #41075
Merged
Merged
Conversation
Nathan Shively-Sanders (sandersn)
requested review from
Anders Hejlsberg (ahejlsberg) and
Wesley Wigham (weswigham)
October 27, 2020 18:12
Member
|
TypeScript Bot (@typescript-bot) perf test this |
Contributor
|
Heya Wesley Wigham (@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! |
Wesley Wigham (weswigham)
approved these changes
Oct 27, 2020
Wesley Wigham (weswigham)
left a comment
Member
There was a problem hiding this comment.
Assuming the perf tests come back OK (always a good idea to check with control flow changes), this looks great to me.
Member
|
Nathan Shively-Sanders (@sandersn) Anders Hejlsberg (@ahejlsberg) should this be 4.1 or 4.2 bound? |
Member
|
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. |
Member
|
If perf looks good I'm fine with having this in 4.1. |
Anders Hejlsberg (ahejlsberg)
approved these changes
Oct 27, 2020
Contributor
|
Wesley Wigham (@weswigham) Here they are:Comparison Report - master..41075
System
Hosts
Scenarios
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 > 0and similar expressions into consideration, which I think is too complex compared to the outcome. How do you think?