mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 14:05:47 -05:00
Simplify index and object types when obtaining indexed access constraint
This commit is contained in:
@@ -7657,15 +7657,20 @@ namespace ts {
|
||||
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined;
|
||||
}
|
||||
|
||||
function getSimplifiedTypeOrConstraint(type: Type) {
|
||||
const simplified = getSimplifiedType(type, /*writing*/ false);
|
||||
return simplified !== type ? simplified : getConstraintOfType(type);
|
||||
}
|
||||
|
||||
function getConstraintFromIndexedAccess(type: IndexedAccessType) {
|
||||
const indexConstraint = getConstraintOfType(type.indexType);
|
||||
const indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
|
||||
if (indexConstraint && indexConstraint !== type.indexType) {
|
||||
const indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint);
|
||||
if (indexedAccess) {
|
||||
return indexedAccess;
|
||||
}
|
||||
}
|
||||
const objectConstraint = getConstraintOfType(type.objectType);
|
||||
const objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
|
||||
if (objectConstraint && objectConstraint !== type.objectType) {
|
||||
return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user