@@ -12325,6 +12325,10 @@ namespace ts {
12325
12325
return result;
12326
12326
}
12327
12327
12328
+ function getAliasId(aliasSymbol: Symbol | undefined, aliasTypeArguments: readonly Type[] | undefined) {
12329
+ return aliasSymbol ? `@${getSymbolId(aliasSymbol)}` + (aliasTypeArguments ? `:${getTypeListId(aliasTypeArguments)}` : "") : "";
12330
+ }
12331
+
12328
12332
// This function is used to propagate certain flags when creating new object type references and union types.
12329
12333
// It is only necessary to do so if a constituent type might be the undefined type, the null type, the type
12330
12334
// of an object literal or the anyFunctionType. This is because there are operations in the type checker
@@ -12453,7 +12457,7 @@ namespace ts {
12453
12457
}
12454
12458
const links = getSymbolLinks(symbol);
12455
12459
const typeParameters = links.typeParameters!;
12456
- const id = getTypeListId(typeArguments) + (aliasSymbol ? `@${getSymbolId(aliasSymbol)}` : "" );
12460
+ const id = getTypeListId(typeArguments) + getAliasId (aliasSymbol, aliasTypeArguments );
12457
12461
let instantiation = links.instantiations!.get(id);
12458
12462
if (!instantiation) {
12459
12463
links.instantiations!.set(id, instantiation = instantiateTypeWithAlias(type,
@@ -13487,7 +13491,7 @@ namespace ts {
13487
13491
origin.flags & TypeFlags.Union ? `|${getTypeListId((<UnionType>origin).types)}` :
13488
13492
origin.flags & TypeFlags.Intersection ? `&${getTypeListId((<IntersectionType>origin).types)}` :
13489
13493
`#${(<IndexType>origin).type.id}`;
13490
- const id = typeKey + (aliasSymbol ? `@${getSymbolId(aliasSymbol)}` : "" );
13494
+ const id = typeKey + getAliasId (aliasSymbol, aliasTypeArguments );
13491
13495
let type = unionTypes.get(id);
13492
13496
if (!type) {
13493
13497
type = createUnionType(types, aliasSymbol, aliasTypeArguments, origin);
@@ -13724,7 +13728,7 @@ namespace ts {
13724
13728
if (typeSet.length === 1) {
13725
13729
return typeSet[0];
13726
13730
}
13727
- const id = getTypeListId(typeSet) + (aliasSymbol ? `@${getSymbolId(aliasSymbol)}` : "" );
13731
+ const id = getTypeListId(typeSet) + getAliasId (aliasSymbol, aliasTypeArguments );
13728
13732
let result = intersectionTypes.get(id);
13729
13733
if (!result) {
13730
13734
if (includes & TypeFlags.Union) {
@@ -14486,7 +14490,7 @@ namespace ts {
14486
14490
return objectType;
14487
14491
}
14488
14492
// Defer the operation by creating an indexed access type.
14489
- const id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : "") + (aliasSymbol ? `@${getSymbolId(aliasSymbol)}` : "" );
14493
+ const id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : "") + getAliasId (aliasSymbol, aliasTypeArguments );
14490
14494
let type = indexedAccessTypes.get(id);
14491
14495
if (!type) {
14492
14496
indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined));
@@ -15481,15 +15485,15 @@ namespace ts {
15481
15485
const combinedMapper = combineTypeMappers(type.mapper, mapper);
15482
15486
const typeArguments = map(typeParameters, t => getMappedType(t, combinedMapper));
15483
15487
const newAliasSymbol = aliasSymbol || type.aliasSymbol;
15484
- const id = getTypeListId(typeArguments) + (newAliasSymbol ? `@${getSymbolId(newAliasSymbol)}` : "");
15488
+ const newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
15489
+ const id = getTypeListId(typeArguments) + getAliasId(newAliasSymbol, newAliasTypeArguments);
15485
15490
if (!target.instantiations) {
15486
15491
target.instantiations = new Map<string, Type>();
15487
- target.instantiations.set(getTypeListId(typeParameters) + (target.aliasSymbol ? `@${getSymbolId( target.aliasSymbol)}` : "" ), target);
15492
+ target.instantiations.set(getTypeListId(typeParameters) + getAliasId (target.aliasSymbol, target.aliasTypeArguments ), target);
15488
15493
}
15489
15494
let result = target.instantiations.get(id);
15490
15495
if (!result) {
15491
15496
const newMapper = createTypeMapper(typeParameters, typeArguments);
15492
- const newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
15493
15497
result = target.objectFlags & ObjectFlags.Reference ? createDeferredTypeReference((<DeferredTypeReference>type).target, (<DeferredTypeReference>type).node, newMapper, newAliasSymbol, newAliasTypeArguments) :
15494
15498
target.objectFlags & ObjectFlags.Mapped ? instantiateMappedType(<MappedType>target, newMapper, newAliasSymbol, newAliasTypeArguments) :
15495
15499
instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
@@ -15657,7 +15661,7 @@ namespace ts {
15657
15661
// mapper to the type parameters to produce the effective list of type arguments, and compute the
15658
15662
// instantiation cache key from the type IDs of the type arguments.
15659
15663
const typeArguments = map(root.outerTypeParameters, t => getMappedType(t, mapper));
15660
- const id = getTypeListId(typeArguments) + (aliasSymbol ? `@${getSymbolId(aliasSymbol)}` : "" );
15664
+ const id = getTypeListId(typeArguments) + getAliasId (aliasSymbol, aliasTypeArguments );
15661
15665
let result = root.instantiations!.get(id);
15662
15666
if (!result) {
15663
15667
const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
0 commit comments