diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 70cbda14f6..b29916c62f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7942,16 +7942,9 @@ namespace ts { } } else if (target.flags & TypeFlags.IndexedAccess) { - // if we have indexed access types with identical index types, see if relationship holds for - // the two object types. - if (source.flags & TypeFlags.IndexedAccess && (source).indexType === (target).indexType) { - if (result = isRelatedTo((source).objectType, (target).objectType, reportErrors)) { - return result; - } - } // A type S is related to a type T[K] if S is related to A[K], where K is string-like and // A is the apparent type of S. - const constraint = getBaseConstraintOfType(target); + const constraint = getConstraintOfType(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; @@ -7998,6 +7991,13 @@ namespace ts { return result; } } + else if (target.flags & TypeFlags.IndexedAccess && (source).indexType === (target).indexType) { + // if we have indexed access types with identical index types, see if relationship holds for + // the two object types. + if (result = isRelatedTo((source).objectType, (target).objectType, reportErrors)) { + return result; + } + } } else { if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) {