@@ -5906,6 +5906,10 @@ namespace ts {
5906
5906
}
5907
5907
5908
5908
function getConstraintOfIndexedAccess(type: IndexedAccessType) {
5909
+ const transformed = getTransformedIndexedAccessType(type);
5910
+ if (transformed) {
5911
+ return transformed;
5912
+ }
5909
5913
const baseObjectType = getBaseConstraintOfType(type.objectType);
5910
5914
const baseIndexType = getBaseConstraintOfType(type.indexType);
5911
5915
return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined;
@@ -7617,8 +7621,8 @@ namespace ts {
7617
7621
return false;
7618
7622
}
7619
7623
7620
- // Transform an indexed access occurring in a read position to a simpler form. Return the simpler form,
7621
- // or undefined if no transformation is possible.
7624
+ // Transform an indexed access to a simpler form, if possible . Return the simpler form, or return
7625
+ // undefined if no transformation is possible.
7622
7626
function getTransformedIndexedAccessType(type: IndexedAccessType): Type {
7623
7627
const objectType = type.objectType;
7624
7628
// Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or
@@ -9279,7 +9283,7 @@ namespace ts {
9279
9283
else if (target.flags & TypeFlags.IndexedAccess) {
9280
9284
// A type S is related to a type T[K] if S is related to A[K], where K is string-like and
9281
9285
// A is the apparent type of S.
9282
- const constraint = getConstraintOfType (<IndexedAccessType>target);
9286
+ const constraint = getConstraintOfIndexedAccess (<IndexedAccessType>target);
9283
9287
if (constraint) {
9284
9288
if (result = isRelatedTo(source, constraint, reportErrors)) {
9285
9289
errorInfo = saveErrorInfo;
@@ -9319,7 +9323,7 @@ namespace ts {
9319
9323
else if (source.flags & TypeFlags.IndexedAccess) {
9320
9324
// A type S[K] is related to a type T if A[K] is related to T, where K is string-like and
9321
9325
// A is the apparent type of S.
9322
- const constraint = getTransformedIndexedAccessType(<IndexedAccessType>source) || getConstraintOfIndexedAccess(<IndexedAccessType>source);
9326
+ const constraint = getConstraintOfIndexedAccess(<IndexedAccessType>source);
9323
9327
if (constraint) {
9324
9328
if (result = isRelatedTo(constraint, target, reportErrors)) {
9325
9329
errorInfo = saveErrorInfo;
0 commit comments