@@ -67,7 +67,6 @@ namespace ts {
67
67
let enumCount = 0;
68
68
let instantiationDepth = 0;
69
69
let constraintDepth = 0;
70
- let simplificationDepth = 0;
71
70
72
71
const emptySymbols = createSymbolTable();
73
72
const identityMapper: (type: Type) => Type = identity;
@@ -9687,31 +9686,15 @@ namespace ts {
9687
9686
9688
9687
// If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper
9689
9688
// that substitutes the index type for P. For example, for an index access { [P in K]: Box<T[P]> }[X], we
9690
- // construct the type Box<T[X]>. Mapped types can be recursive so to guard against infinite recursion we
9691
- // only perform this simplification up to five levels deep.
9692
- if (simplificationDepth < 5) {
9693
- if (isGenericMappedType(objectType)) {
9694
- return type.simplified = substituteIndexedMappedType(objectType, type);
9695
- }
9696
- if (objectType.flags & TypeFlags.TypeParameter) {
9697
- const constraint = getConstraintOfTypeParameter(objectType as TypeParameter);
9698
- if (constraint && isGenericMappedType(constraint)) {
9699
- return type.simplified = substituteIndexedMappedType(constraint, type);
9700
- }
9701
- }
9689
+ // construct the type Box<T[X]>.
9690
+ if (isGenericMappedType(objectType)) {
9691
+ const mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [type.indexType]);
9692
+ const templateMapper = combineTypeMappers(objectType.mapper, mapper);
9693
+ return type.simplified = mapType(instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper), getSimplifiedType);
9702
9694
}
9703
9695
return type.simplified = type;
9704
9696
}
9705
9697
9706
- function substituteIndexedMappedType(objectType: MappedType, type: IndexedAccessType) {
9707
- simplificationDepth++;
9708
- const mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [type.indexType]);
9709
- const templateMapper = combineTypeMappers(objectType.mapper, mapper);
9710
- const result = mapType(instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper), getSimplifiedType);
9711
- simplificationDepth--;
9712
- return result;
9713
- }
9714
-
9715
9698
function getIndexedAccessType(objectType: Type, indexType: Type, accessNode?: ElementAccessExpression | IndexedAccessTypeNode | PropertyName, missingType = accessNode ? errorType : unknownType): Type {
9716
9699
if (objectType === wildcardType || indexType === wildcardType) {
9717
9700
return wildcardType;
0 commit comments