Properly reduce intersections to never in identity relation (#48111)

* Exclude types that may simplify to other forms

* Add regression test
This commit is contained in:
Anders Hejlsberg
2022-03-11 10:18:04 -08:00
committed by GitHub
parent 04238e6f52
commit 0271738047
5 changed files with 181 additions and 1 deletions

View File

@@ -18104,7 +18104,8 @@ namespace ts {
return true;
}
}
else {
else if (!((source.flags | target.flags) & (TypeFlags.UnionOrIntersection | TypeFlags.IndexedAccess | TypeFlags.Conditional | TypeFlags.Substitution))) {
// We have excluded types that may simplify to other forms, so types must have identical flags
if (source.flags !== target.flags) return false;
if (source.flags & TypeFlags.Singleton) return true;
}