mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 10:58:20 -05:00
ignore undefined type guards
This commit is contained in:
@@ -6479,6 +6479,10 @@ namespace ts {
|
||||
assumeTrue = !assumeTrue;
|
||||
}
|
||||
const typeInfo = primitiveTypeInfo[right.text];
|
||||
// Don't narrow `undefined`
|
||||
if (typeInfo && typeInfo.type === undefinedType) {
|
||||
return type;
|
||||
}
|
||||
// If the type to be narrowed is any and we're checking a primitive with assumeTrue=true, return the primitive
|
||||
if (!!(type.flags & TypeFlags.Any) && typeInfo && assumeTrue) {
|
||||
return typeInfo.type;
|
||||
|
||||
Reference in New Issue
Block a user