@@ -55321,13 +55321,16 @@ function createTypeChecker(host) {
55321
55321
const constraint = getConstraintTypeFromMappedType(type);
55322
55322
if (constraint.flags & 4194304 /* Index */) {
55323
55323
const baseConstraint = getBaseConstraintOfType(constraint.type);
55324
- if (baseConstraint && everyType(baseConstraint, isArrayOrTupleType)) {
55324
+ if (baseConstraint && everyType(baseConstraint, (t) => isArrayOrTupleType(t) || isArrayOrTupleOrIntersection(t) )) {
55325
55325
return instantiateType(target, prependTypeMapping(typeVariable, baseConstraint, type.mapper));
55326
55326
}
55327
55327
}
55328
55328
}
55329
55329
return type;
55330
55330
}
55331
+ function isArrayOrTupleOrIntersection(type) {
55332
+ return !!(type.flags & 2097152 /* Intersection */) && every(type.types, isArrayOrTupleType);
55333
+ }
55331
55334
function isMappedTypeGenericIndexedAccess(type) {
55332
55335
let objectType;
55333
55336
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) {
59698
59701
if (typeVariable) {
59699
59702
const mappedTypeVariable = instantiateType(typeVariable, mapper);
59700
59703
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);
59721
59705
}
59722
59706
}
59723
59707
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
+ }
59724
59726
}
59725
59727
function getModifiedReadonlyState(state, modifiers) {
59726
59728
return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state;
0 commit comments