Use immediate constraint, not base constraint, of indexed access
This commit is contained in:
parent
9e8b3d9c3b
commit
cca7ac2557
|
@ -7942,16 +7942,9 @@ namespace ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (target.flags & TypeFlags.IndexedAccess) {
|
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 && (<IndexedAccessType>source).indexType === (<IndexedAccessType>target).indexType) {
|
|
||||||
if (result = isRelatedTo((<IndexedAccessType>source).objectType, (<IndexedAccessType>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 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.
|
// A is the apparent type of S.
|
||||||
const constraint = getBaseConstraintOfType(target);
|
const constraint = getConstraintOfType(<IndexedAccessType>target);
|
||||||
if (constraint) {
|
if (constraint) {
|
||||||
if (result = isRelatedTo(source, constraint, reportErrors)) {
|
if (result = isRelatedTo(source, constraint, reportErrors)) {
|
||||||
errorInfo = saveErrorInfo;
|
errorInfo = saveErrorInfo;
|
||||||
|
@ -7998,6 +7991,13 @@ namespace ts {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (target.flags & TypeFlags.IndexedAccess && (<IndexedAccessType>source).indexType === (<IndexedAccessType>target).indexType) {
|
||||||
|
// if we have indexed access types with identical index types, see if relationship holds for
|
||||||
|
// the two object types.
|
||||||
|
if (result = isRelatedTo((<IndexedAccessType>source).objectType, (<IndexedAccessType>target).objectType, reportErrors)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
|
if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
|
||||||
|
|
Loading…
Reference in a new issue