ignore undefined type guards

This commit is contained in:
Wesley Wigham
2015-11-13 14:08:26 -08:00
parent 581f52a7ea
commit 16d80ebe71

View File

@@ -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;