Quick bail out when narrowing type any by equality

This commit is contained in:
Anders Hejlsberg
2016-09-13 08:55:29 -07:00
committed by Mohamed Hegazy
parent b8759b38ee
commit 88349ab436
+3
View File
@@ -8522,6 +8522,9 @@ namespace ts {
}
function narrowTypeByEquality(type: Type, operator: SyntaxKind, value: Expression, assumeTrue: boolean): Type {
if (type.flags & TypeFlags.Any) {
return type;
}
if (operator === SyntaxKind.ExclamationEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) {
assumeTrue = !assumeTrue;
}