mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
Merge pull request #13234 from Microsoft/fixMappedTypeInstantiation
Fix mapped type instantiation
This commit is contained in:
@@ -6652,17 +6652,19 @@ namespace ts {
|
||||
const constraintType = getConstraintTypeFromMappedType(type);
|
||||
if (constraintType.flags & TypeFlags.Index) {
|
||||
const typeVariable = (<IndexType>constraintType).type;
|
||||
const mappedTypeVariable = instantiateType(typeVariable, mapper);
|
||||
if (typeVariable !== mappedTypeVariable) {
|
||||
return mapType(mappedTypeVariable, t => {
|
||||
if (isMappableType(t)) {
|
||||
const replacementMapper = createUnaryTypeMapper(typeVariable, t);
|
||||
const combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper);
|
||||
combinedMapper.mappedTypes = mapper.mappedTypes;
|
||||
return instantiateMappedObjectType(type, combinedMapper);
|
||||
}
|
||||
return t;
|
||||
});
|
||||
if (typeVariable.flags & TypeFlags.TypeParameter) {
|
||||
const mappedTypeVariable = instantiateType(typeVariable, mapper);
|
||||
if (typeVariable !== mappedTypeVariable) {
|
||||
return mapType(mappedTypeVariable, t => {
|
||||
if (isMappableType(t)) {
|
||||
const replacementMapper = createUnaryTypeMapper(typeVariable, t);
|
||||
const combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper);
|
||||
combinedMapper.mappedTypes = mapper.mappedTypes;
|
||||
return instantiateMappedObjectType(type, combinedMapper);
|
||||
}
|
||||
return t;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return instantiateMappedObjectType(type, mapper);
|
||||
|
||||
Reference in New Issue
Block a user