Quick bail out when narrowing type any by equality

This commit is contained in:
Anders Hejlsberg authored and Mohamed Hegazy committed 2016-09-13 08:55:29 -07:00
1 parent b8759b38ee
commit 88349ab436
1 file changed
+3
+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;
}