@@ -10670,23 +10670,8 @@ namespace ts {
10670
10670
}
10671
10671
}
10672
10672
10673
- if (source.flags & TypeFlags.TypeParameter) {
10674
- let constraint = getConstraintForRelation(<TypeParameter>source);
10675
- // A type parameter with no constraint is not related to the non-primitive object type.
10676
- if (constraint || !(target.flags & TypeFlags.NonPrimitive)) {
10677
- if (!constraint || constraint.flags & TypeFlags.Any) {
10678
- constraint = emptyObjectType;
10679
- }
10680
- // Report constraint errors only if the constraint is not the empty object type
10681
- const reportConstraintErrors = reportErrors && constraint !== emptyObjectType;
10682
- if (result = isRelatedTo(constraint, target, reportConstraintErrors)) {
10683
- errorInfo = saveErrorInfo;
10684
- return result;
10685
- }
10686
- }
10687
- }
10688
- else if (source.flags & TypeFlags.IndexedAccess) {
10689
- if (target.flags & TypeFlags.IndexedAccess) {
10673
+ if (source.flags & TypeFlags.TypeVariable) {
10674
+ if (source.flags & TypeFlags.IndexedAccess && target.flags & TypeFlags.IndexedAccess) {
10690
10675
// A type S[K] is related to a type T[J] if S is related to T and K is related to J.
10691
10676
if (result = isRelatedTo((<IndexedAccessType>source).objectType, (<IndexedAccessType>target).objectType, reportErrors)) {
10692
10677
result &= isRelatedTo((<IndexedAccessType>source).indexType, (<IndexedAccessType>target).indexType, reportErrors);
@@ -10696,11 +10681,15 @@ namespace ts {
10696
10681
return result;
10697
10682
}
10698
10683
}
10699
- // A type S[K] is related to a type T if C is related to T, where C is the
10700
- // constraint of S[K].
10701
- const constraint = getConstraintForRelation(<IndexedAccessType>source);
10702
- if (constraint) {
10703
- if (result = isRelatedTo(constraint, target, reportErrors)) {
10684
+ let constraint = getConstraintForRelation(<TypeParameter>source);
10685
+ // A type variable with no constraint is not related to the non-primitive object type.
10686
+ if (constraint || !(target.flags & TypeFlags.NonPrimitive)) {
10687
+ if (!constraint || constraint.flags & TypeFlags.Any) {
10688
+ constraint = emptyObjectType;
10689
+ }
10690
+ // Report constraint errors only if the constraint is not the empty object type
10691
+ const reportConstraintErrors = reportErrors && constraint !== emptyObjectType;
10692
+ if (result = isRelatedTo(constraint, target, reportConstraintErrors)) {
10704
10693
errorInfo = saveErrorInfo;
10705
10694
return result;
10706
10695
}
0 commit comments