@@ -7777,7 +7777,7 @@ namespace ts {
7777
7777
// expression constructs such as array literals and the || and ?: operators). Named types can
7778
7778
// circularly reference themselves and therefore cannot be subtype reduced during their declaration.
7779
7779
// For example, "type Item = string | (() => Item" is a named type that circularly references itself.
7780
- function getUnionType(types: Type[], subtypeReduction?: boolean, aliasSymbol?: Symbol, aliasTypeArguments?: Type[]): Type {
7780
+ function getUnionType(types: Type[], subtypeReduction?: boolean, aliasSymbol?: Symbol, aliasTypeArguments?: Type[], noReductions?: boolean ): Type {
7781
7781
if (types.length === 0) {
7782
7782
return neverType;
7783
7783
}
@@ -7789,11 +7789,13 @@ namespace ts {
7789
7789
if (typeSet.containsAny) {
7790
7790
return anyType;
7791
7791
}
7792
- if (subtypeReduction) {
7793
- removeSubtypes(typeSet);
7794
- }
7795
- else if (typeSet.containsLiteralOrUniqueESSymbol) {
7796
- removeRedundantLiteralTypes(typeSet);
7792
+ if (!noReductions) {
7793
+ if (subtypeReduction) {
7794
+ removeSubtypes(typeSet);
7795
+ }
7796
+ else if (typeSet.containsLiteralOrUniqueESSymbol) {
7797
+ removeRedundantLiteralTypes(typeSet);
7798
+ }
7797
7799
}
7798
7800
if (typeSet.length === 0) {
7799
7801
return typeSet.containsNull ? typeSet.containsNonWideningType ? nullType : nullWideningType :
@@ -12104,7 +12106,7 @@ namespace ts {
12104
12106
// Apply a mapping function to a type and return the resulting type. If the source type
12105
12107
// is a union type, the mapping function is applied to each constituent type and a union
12106
12108
// of the resulting types is returned.
12107
- function mapType(type: Type, mapper: (t: Type) => Type): Type {
12109
+ function mapType(type: Type, mapper: (t: Type) => Type, noReductions?: boolean ): Type {
12108
12110
if (!(type.flags & TypeFlags.Union)) {
12109
12111
return mapper(type);
12110
12112
}
@@ -12125,7 +12127,7 @@ namespace ts {
12125
12127
}
12126
12128
}
12127
12129
}
12128
- return mappedTypes ? getUnionType(mappedTypes) : mappedType;
12130
+ return mappedTypes ? getUnionType(mappedTypes, /*subtypeReduction*/ undefined, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, noReductions ) : mappedType;
12129
12131
}
12130
12132
12131
12133
function extractTypesOfKind(type: Type, kind: TypeFlags) {
@@ -13911,7 +13913,7 @@ namespace ts {
13911
13913
return mapType(type, t => {
13912
13914
const prop = t.flags & TypeFlags.StructuredType ? getPropertyOfType(t, name) : undefined;
13913
13915
return prop ? getTypeOfSymbol(prop) : undefined;
13914
- });
13916
+ }, /*noReductions*/ true );
13915
13917
}
13916
13918
13917
13919
function getIndexTypeOfContextualType(type: Type, kind: IndexKind) {
0 commit comments