Chain RHS narrowing and truthiness narrowing in assignment expression narrowing (#31348)

This commit is contained in:
Wesley Wigham
2019-05-13 14:41:33 -07:00
committed by GitHub
parent 546028156e
commit f140dfc30b
9 changed files with 194 additions and 15 deletions

View File

@@ -16773,7 +16773,7 @@ namespace ts {
function narrowTypeByBinaryExpression(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type {
switch (expr.operatorToken.kind) {
case SyntaxKind.EqualsToken:
return narrowTypeByTruthiness(type, expr.left, assumeTrue);
return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue);
case SyntaxKind.EqualsEqualsToken:
case SyntaxKind.ExclamationEqualsToken:
case SyntaxKind.EqualsEqualsEqualsToken: