Discard union types before considering weak type checks on unit-like types (#50423)

* Only check isUnitType when dealing with non-unions.

* Add test case.

* Accepted baselines.
This commit is contained in:
Daniel Rosenwasser
2022-08-24 11:39:00 -07:00
committed by GitHub
parent b9a5bbc9af
commit fb717df6bf
5 changed files with 315 additions and 1 deletions

View File

@@ -18901,7 +18901,7 @@ namespace ts {
}
}
const isPerformingCommonPropertyChecks = (relation !== comparableRelation || relation === comparableRelation && isLiteralType(source)) &&
const isPerformingCommonPropertyChecks = (relation !== comparableRelation || !(source.flags & TypeFlags.Union) && isLiteralType(source)) &&
!(intersectionState & IntersectionState.Target) &&
source.flags & (TypeFlags.Primitive | TypeFlags.Object | TypeFlags.Intersection) && source !== globalObjectType &&
target.flags & (TypeFlags.Object | TypeFlags.Intersection) && isWeakType(target) &&