@@ -10022,7 +10022,8 @@ namespace ts {
10022
10022
}
10023
10023
}
10024
10024
else if (type.flags & TypeFlags.Intersection) {
10025
- return getIntersectionType(map((<IntersectionType>type).types, t => getTypeWithThisArgument(t, thisArgument, needApparentType)));
10025
+ const types = sameMap((<IntersectionType>type).types, t => getTypeWithThisArgument(t, thisArgument, needApparentType));
10026
+ return types !== (<IntersectionType>type).types ? getIntersectionType(types) : type;
10026
10027
}
10027
10028
return needApparentType ? getApparentType(type) : type;
10028
10029
}
@@ -13348,7 +13349,7 @@ namespace ts {
13348
13349
if (types.length === 1) {
13349
13350
return types[0];
13350
13351
}
13351
- const id = getTypeListId(types) + ( origin ? `${origin.isIntersection ? '&' : '|' }${getTypeListId(origin.types)}` : "" ) + (aliasSymbol ? `@${getSymbolId(aliasSymbol)}` : "");
13352
+ const id = ( origin ? `${origin.isIntersection ? "&" : "|" }${getTypeListId(origin.types)}` : getTypeListId(types) ) + (aliasSymbol ? `@${getSymbolId(aliasSymbol)}` : "");
13352
13353
let type = unionTypes.get(id);
13353
13354
if (!type) {
13354
13355
type = <UnionType>createType(TypeFlags.Union);
@@ -13595,7 +13596,7 @@ namespace ts {
13595
13596
if (typeSet.length === 1) {
13596
13597
return typeSet[0];
13597
13598
}
13598
- const id = getTypeListId(typeSet);
13599
+ const id = getTypeListId(typeSet) + (aliasSymbol ? `@${getSymbolId(aliasSymbol)}` : "") ;
13599
13600
let result = intersectionTypes.get(id);
13600
13601
if (!result) {
13601
13602
if (includes & TypeFlags.Union) {
@@ -13606,10 +13607,10 @@ namespace ts {
13606
13607
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
13607
13608
}
13608
13609
else if (extractIrreducible(typeSet, TypeFlags.Undefined)) {
13609
- result = getUnionTypeFromIntersection([getIntersectionType(typeSet), undefinedType], aliasSymbol, aliasTypeArguments, typeSet );
13610
+ result = getUnionTypeFromIntersection([getIntersectionType(typeSet), undefinedType], aliasSymbol, aliasTypeArguments);
13610
13611
}
13611
13612
else if (extractIrreducible(typeSet, TypeFlags.Null)) {
13612
- result = getUnionTypeFromIntersection([getIntersectionType(typeSet), nullType], aliasSymbol, aliasTypeArguments, typeSet );
13613
+ result = getUnionTypeFromIntersection([getIntersectionType(typeSet), nullType], aliasSymbol, aliasTypeArguments);
13613
13614
}
13614
13615
else {
13615
13616
// We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of
@@ -13632,8 +13633,8 @@ namespace ts {
13632
13633
return result;
13633
13634
}
13634
13635
13635
- function getUnionTypeFromIntersection(types: readonly Type[], aliasSymbol: Symbol | undefined, aliasTypeArguments: readonly Type[] | undefined, originalTypes: readonly Type[]) {
13636
- const origin = some(types, t => !!(t.flags & TypeFlags.Intersection)) ? { types: originalTypes, isIntersection: true } : undefined;
13636
+ function getUnionTypeFromIntersection(types: readonly Type[], aliasSymbol: Symbol | undefined, aliasTypeArguments: readonly Type[] | undefined, originalTypes? : readonly Type[]) {
13637
+ const origin = originalTypes && some(types, t => !!(t.flags & TypeFlags.Intersection)) ? { types: originalTypes, isIntersection: true } : undefined;
13637
13638
return getUnionType(types, UnionReduction.Literal, aliasSymbol, aliasTypeArguments, origin);
13638
13639
}
13639
13640
@@ -14328,7 +14329,7 @@ namespace ts {
14328
14329
return objectType;
14329
14330
}
14330
14331
// Defer the operation by creating an indexed access type.
14331
- const id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : "");
14332
+ const id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : "") + (aliasSymbol ? `@${getSymbolId(aliasSymbol)}` : "") ;
14332
14333
let type = indexedAccessTypes.get(id);
14333
14334
if (!type) {
14334
14335
indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined));
0 commit comments