Skip to content

Fix narrow-by-constructor logic#37698

Merged
ahejlsberg merged 2 commits intomasterfrom
fix37660
Mar 31, 2020
Merged

Fix narrow-by-constructor logic#37698
ahejlsberg merged 2 commits intomasterfrom
fix37660

Conversation

@ahejlsberg
Copy link
Copy Markdown
Member

This PR fixes two issues in the narrow-by-constructor logic that was added in #32774:

  • Removes unnecessary resetting of control flow type to the declared type.
  • Reorganizes logic and adds a missing isMatchingReference check, the absence of which would cause constructor checks to erroneously narrow all references in the code path.

Fixes #37660.

@ahejlsberg ahejlsberg merged commit 2b0f351 into master Mar 31, 2020
@ahejlsberg ahejlsberg added this to the TypeScript 3.9.1 milestone Mar 31, 2020
@ahejlsberg
Copy link
Copy Markdown
Member Author

@RyanCavanaugh We should pull this fix into the next 3.9 release.

@jakebailey jakebailey deleted the fix37660 branch November 7, 2022 17:36
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
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.

[3.9.0-beta] Type gets incorrectly un-narrowed after ifs

2 participants