From ea96dfd364f78caf397a21416765a2f48ae55434 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 20 Apr 2016 06:59:28 -0700 Subject: [PATCH] Support comma operator in type guards --- src/compiler/binder.ts | 2 ++ src/compiler/checker.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 6eefd7c6ef9..91f4247a673 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -630,6 +630,8 @@ namespace ts { return false; case SyntaxKind.InstanceOfKeyword: return isNarrowingExpression(expr.left); + case SyntaxKind.CommaToken: + return isNarrowingExpression(expr.right); } return false; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4731046864e..09d70ac3684 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7677,6 +7677,8 @@ namespace ts { break; case SyntaxKind.InstanceOfKeyword: return narrowTypeByInstanceof(type, expr, assumeTrue); + case SyntaxKind.CommaToken: + return narrowType(type, expr.right, assumeTrue); } return type; }