Skip to content

Commit ea96dfd

Browse files
committed
Support comma operator in type guards
1 parent c8bf6d8 commit ea96dfd

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

src/compiler/binder.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,8 @@ namespace ts {
630630
return false;
631631
case SyntaxKind.InstanceOfKeyword:
632632
return isNarrowingExpression(expr.left);
633+
case SyntaxKind.CommaToken:
634+
return isNarrowingExpression(expr.right);
633635
}
634636
return false;
635637
}

src/compiler/checker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7677,6 +7677,8 @@ namespace ts {
76777677
break;
76787678
case SyntaxKind.InstanceOfKeyword:
76797679
return narrowTypeByInstanceof(type, expr, assumeTrue);
7680+
case SyntaxKind.CommaToken:
7681+
return narrowType(type, expr.right, assumeTrue);
76807682
}
76817683
return type;
76827684
}

0 commit comments

Comments
 (0)