diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 91f4247a673..3d6db01580a 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -617,6 +617,8 @@ namespace ts { function isNarrowingBinaryExpression(expr: BinaryExpression) { switch (expr.operatorToken.kind) { + case SyntaxKind.EqualsToken: + return isNarrowableReference(expr.left); case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 195245648a7..a3b3451fe35 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7671,6 +7671,8 @@ namespace ts { function narrowTypeByBinaryExpression(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type { switch (expr.operatorToken.kind) { + case SyntaxKind.EqualsToken: + return narrowTypeByTruthiness(type, expr.left, assumeTrue); case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: