Skip to content

Commit 16d80eb

Browse files
committed
ignore undefined type guards
1 parent 581f52a commit 16d80eb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6479,6 +6479,10 @@ namespace ts {
64796479
assumeTrue = !assumeTrue;
64806480
}
64816481
const typeInfo = primitiveTypeInfo[right.text];
6482+
// Don't narrow `undefined`
6483+
if (typeInfo && typeInfo.type === undefinedType) {
6484+
return type;
6485+
}
64826486
// If the type to be narrowed is any and we're checking a primitive with assumeTrue=true, return the primitive
64836487
if (!!(type.flags & TypeFlags.Any) && typeInfo && assumeTrue) {
64846488
return typeInfo.type;

0 commit comments

Comments
 (0)