Cherry-pick PR #38395 into release-3.9 (#38402)

Component commits:
6fe4be21e4 Exclude arrays and tuples from full intersection property check

9019e399e5 Add regression test

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
This commit is contained in:
Daniel Rosenwasser
2020-05-07 23:56:33 -07:00
committed by GitHub
6 changed files with 39 additions and 1 deletions

View File

@@ -15827,7 +15827,7 @@ namespace ts {
// recursive intersections that are structurally similar but not exactly identical. See #37854.
if (result && !inPropertyCheck && (
target.flags & TypeFlags.Intersection && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
isNonGenericObjectType(target) && source.flags & TypeFlags.Intersection && getApparentType(source).flags & TypeFlags.StructuredType && !some((<IntersectionType>source).types, t => !!(getObjectFlags(t) & ObjectFlags.NonInferrableType)))) {
isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & TypeFlags.Intersection && getApparentType(source).flags & TypeFlags.StructuredType && !some((<IntersectionType>source).types, t => !!(getObjectFlags(t) & ObjectFlags.NonInferrableType)))) {
inPropertyCheck = true;
result &= recursiveTypeRelatedTo(source, target, reportErrors, IntersectionState.PropertyCheck);
inPropertyCheck = false;