@@ -55321,13 +55321,16 @@ function createTypeChecker(host) {
5532155321 const constraint = getConstraintTypeFromMappedType(type);
5532255322 if (constraint.flags & 4194304 /* Index */) {
5532355323 const baseConstraint = getBaseConstraintOfType(constraint.type);
55324- if (baseConstraint && everyType(baseConstraint, isArrayOrTupleType)) {
55324+ if (baseConstraint && everyType(baseConstraint, (t) => isArrayOrTupleType(t) || isArrayOrTupleOrIntersection(t) )) {
5532555325 return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
5532655326 }
5532755327 }
5532855328 }
5532955329 return type;
5533055330 }
55331+ function isArrayOrTupleOrIntersection(type) {
55332+ return !!(type.flags & 2097152 /* Intersection */) && every(type.types, isArrayOrTupleType);
55333+ }
5533155334 function isMappedTypeGenericIndexedAccess(type) {
5533255335 let objectType;
5533355336 return !!(type.flags & 8388608 /* IndexedAccess */ && getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
@@ -59698,29 +59701,28 @@ function createTypeChecker(host) {
5969859701 if (typeVariable) {
5969959702 const mappedTypeVariable = instantiateType(typeVariable, mapper);
5970059703 if (typeVariable !== mappedTypeVariable) {
59701- return mapTypeWithAlias(
59702- getReducedType(mappedTypeVariable),
59703- (t) => {
59704- if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
59705- if (!type.declaration.nameType) {
59706- let constraint;
59707- if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
59708- return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
59709- }
59710- if (isTupleType(t)) {
59711- return instantiateMappedTupleType(t, type, typeVariable, mapper);
59712- }
59713- }
59714- return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
59715- }
59716- return t;
59717- },
59718- aliasSymbol,
59719- aliasTypeArguments
59720- );
59704+ return mapTypeWithAlias(getReducedType(mappedTypeVariable), instantiateConstituent, aliasSymbol, aliasTypeArguments);
5972159705 }
5972259706 }
5972359707 return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments);
59708+ function instantiateConstituent(t) {
59709+ if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
59710+ if (!type.declaration.nameType) {
59711+ let constraint;
59712+ if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
59713+ return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
59714+ }
59715+ if (isTupleType(t)) {
59716+ return instantiateMappedTupleType(t, type, typeVariable, mapper);
59717+ }
59718+ if (isArrayOrTupleOrIntersection(t)) {
59719+ return getIntersectionType(map(t.types, instantiateConstituent));
59720+ }
59721+ }
59722+ return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
59723+ }
59724+ return t;
59725+ }
5972459726 }
5972559727 function getModifiedReadonlyState(state, modifiers) {
5972659728 return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state;
0 commit comments