Properly instantiate aliasTypeArguments
This commit is contained in:
parent
ed4fead087
commit
da7f11fe4b
2 changed files with 16 additions and 10 deletions
|
@ -4164,8 +4164,8 @@ namespace ts {
|
||||||
else {
|
else {
|
||||||
mapper = createTypeMapper(typeParameters, typeArguments);
|
mapper = createTypeMapper(typeParameters, typeArguments);
|
||||||
members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1);
|
members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1);
|
||||||
callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature);
|
callSignatures = instantiateSignatures(source.declaredCallSignatures, mapper);
|
||||||
constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature);
|
constructSignatures = instantiateSignatures(source.declaredConstructSignatures, mapper);
|
||||||
stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper);
|
stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper);
|
||||||
numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper);
|
numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper);
|
||||||
}
|
}
|
||||||
|
@ -4363,8 +4363,8 @@ namespace ts {
|
||||||
const symbol = type.symbol;
|
const symbol = type.symbol;
|
||||||
if (type.target) {
|
if (type.target) {
|
||||||
const members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
|
const members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
|
||||||
const callSignatures = instantiateList(getSignaturesOfType(type.target, SignatureKind.Call), type.mapper, instantiateSignature);
|
const callSignatures = instantiateSignatures(getSignaturesOfType(type.target, SignatureKind.Call), type.mapper);
|
||||||
const constructSignatures = instantiateList(getSignaturesOfType(type.target, SignatureKind.Construct), type.mapper, instantiateSignature);
|
const constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, SignatureKind.Construct), type.mapper);
|
||||||
const stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, IndexKind.String), type.mapper);
|
const stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, IndexKind.String), type.mapper);
|
||||||
const numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, IndexKind.Number), type.mapper);
|
const numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, IndexKind.Number), type.mapper);
|
||||||
setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
|
setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
|
||||||
|
@ -6037,6 +6037,14 @@ namespace ts {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function instantiateTypes(types: Type[], mapper: TypeMapper) {
|
||||||
|
return instantiateList(types, mapper, instantiateType);
|
||||||
|
}
|
||||||
|
|
||||||
|
function instantiateSignatures(signatures: Signature[], mapper: TypeMapper) {
|
||||||
|
return instantiateList(signatures, mapper, instantiateSignature);
|
||||||
|
}
|
||||||
|
|
||||||
function createUnaryTypeMapper(source: Type, target: Type): TypeMapper {
|
function createUnaryTypeMapper(source: Type, target: Type): TypeMapper {
|
||||||
return t => t === source ? target : t;
|
return t => t === source ? target : t;
|
||||||
}
|
}
|
||||||
|
@ -6063,7 +6071,6 @@ namespace ts {
|
||||||
count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) :
|
count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) :
|
||||||
createArrayTypeMapper(sources, targets);
|
createArrayTypeMapper(sources, targets);
|
||||||
mapper.mappedTypes = sources;
|
mapper.mappedTypes = sources;
|
||||||
mapper.targetTypes = targets;
|
|
||||||
return mapper;
|
return mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6190,7 +6197,7 @@ namespace ts {
|
||||||
result.target = type;
|
result.target = type;
|
||||||
result.mapper = mapper;
|
result.mapper = mapper;
|
||||||
result.aliasSymbol = type.aliasSymbol;
|
result.aliasSymbol = type.aliasSymbol;
|
||||||
result.aliasTypeArguments = mapper.targetTypes;
|
result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper);
|
||||||
mapper.instantiations[type.id] = result;
|
mapper.instantiations[type.id] = result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -6266,14 +6273,14 @@ namespace ts {
|
||||||
instantiateAnonymousType(<AnonymousType>type, mapper) : type;
|
instantiateAnonymousType(<AnonymousType>type, mapper) : type;
|
||||||
}
|
}
|
||||||
if ((<ObjectType>type).objectFlags & ObjectFlags.Reference) {
|
if ((<ObjectType>type).objectFlags & ObjectFlags.Reference) {
|
||||||
return createTypeReference((<TypeReference>type).target, instantiateList((<TypeReference>type).typeArguments, mapper, instantiateType));
|
return createTypeReference((<TypeReference>type).target, instantiateTypes((<TypeReference>type).typeArguments, mapper));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Primitive)) {
|
if (type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Primitive)) {
|
||||||
return getUnionType(instantiateList((<UnionType>type).types, mapper, instantiateType), /*subtypeReduction*/ false, type.aliasSymbol, mapper.targetTypes);
|
return getUnionType(instantiateTypes((<UnionType>type).types, mapper), /*subtypeReduction*/ false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper));
|
||||||
}
|
}
|
||||||
if (type.flags & TypeFlags.Intersection) {
|
if (type.flags & TypeFlags.Intersection) {
|
||||||
return getIntersectionType(instantiateList((<IntersectionType>type).types, mapper, instantiateType), type.aliasSymbol, mapper.targetTypes);
|
return getIntersectionType(instantiateTypes((<IntersectionType>type).types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper));
|
||||||
}
|
}
|
||||||
if (type.flags & TypeFlags.Index) {
|
if (type.flags & TypeFlags.Index) {
|
||||||
return getIndexType(instantiateType((<IndexType>type).type, mapper));
|
return getIndexType(instantiateType((<IndexType>type).type, mapper));
|
||||||
|
|
|
@ -2940,7 +2940,6 @@ namespace ts {
|
||||||
export interface TypeMapper {
|
export interface TypeMapper {
|
||||||
(t: TypeParameter): Type;
|
(t: TypeParameter): Type;
|
||||||
mappedTypes?: Type[]; // Types mapped by this mapper
|
mappedTypes?: Type[]; // Types mapped by this mapper
|
||||||
targetTypes?: Type[]; // Types substituted for mapped types
|
|
||||||
instantiations?: Type[]; // Cache of instantiations created using this type mapper.
|
instantiations?: Type[]; // Cache of instantiations created using this type mapper.
|
||||||
context?: InferenceContext; // The inference context this mapper was created from.
|
context?: InferenceContext; // The inference context this mapper was created from.
|
||||||
// Only inference mappers have this set (in createInferenceMapper).
|
// Only inference mappers have this set (in createInferenceMapper).
|
||||||
|
|
Loading…
Reference in a new issue