Skip to content

Commit 9812ab5

Browse files
authored
Merge pull request #10870 from Microsoft/fixNarrowingWithAny
Fix equality narrowing with any
2 parents f16edf9 + 208b341 commit 9812ab5

File tree

5 files changed

+6935
-0
lines changed

5 files changed

+6935
-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)