Skip to content

Commit 6e8182d

Browse files
committed
Quick bail out when narrowing type any by equality
1 parent 37d6ab3 commit 6e8182d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8586,6 +8586,9 @@ namespace ts {
85868586
}
85878587

85888588
function narrowTypeByEquality(type: Type, operator: SyntaxKind, value: Expression, assumeTrue: boolean): Type {
8589+
if (type.flags & TypeFlags.Any) {
8590+
return type;
8591+
}
85898592
if (operator === SyntaxKind.ExclamationEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) {
85908593
assumeTrue = !assumeTrue;
85918594
}

0 commit comments

Comments
 (0)