Use bidirectional comparability in narrowing (#50592)

* Use bidirectional comparability (aka comparability) in narrowing

* Rename test, check other CFA branch, test without strictNullChecks
This commit is contained in:
Andrew Branch
2022-09-01 14:26:48 -07:00
committed by GitHub
parent 891cdc58aa
commit 5df09a514c
8 changed files with 207 additions and 1 deletions

View File

@@ -25096,7 +25096,7 @@ namespace ts {
const narrowedPropType = narrowType(propType);
return filterType(type, t => {
const discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
return !(narrowedPropType.flags & TypeFlags.Never) && isTypeComparableTo(narrowedPropType, discriminantType);
return !(narrowedPropType.flags & TypeFlags.Never) && areTypesComparable(narrowedPropType, discriminantType);
});
}