mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 11:24:29 -05:00
Propagate nonInferrableType in &&, || and ?? operators (#38035)
* Propagate nonInferrableType in &&, || and ?? operators * Add regression test * Simpler solution: getTypeFacts(neverType) should return TypeFacts.None
This commit is contained in:
@@ -19390,6 +19390,9 @@ namespace ts {
|
||||
if (flags & TypeFlags.NonPrimitive) {
|
||||
return strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts;
|
||||
}
|
||||
if (flags & TypeFlags.Never) {
|
||||
return TypeFacts.None;
|
||||
}
|
||||
if (flags & TypeFlags.Instantiable) {
|
||||
return getTypeFacts(getBaseConstraintOfType(type) || unknownType);
|
||||
}
|
||||
@@ -19626,7 +19629,7 @@ namespace ts {
|
||||
const filtered = filter(types, f);
|
||||
return filtered === types ? type : getUnionTypeFromSortedList(filtered, (<UnionType>type).objectFlags);
|
||||
}
|
||||
return f(type) ? type : neverType;
|
||||
return type.flags & TypeFlags.Never || f(type) ? type : neverType;
|
||||
}
|
||||
|
||||
function countTypes(type: Type) {
|
||||
|
||||
Reference in New Issue
Block a user