@@ -1548,7 +1548,7 @@ namespace ts {
1548
1548
}
1549
1549
1550
1550
function createBooleanType(trueFalseTypes: Type[]): IntrinsicType & UnionType {
1551
- const type = <IntrinsicType & UnionType>getUnionType(trueFalseTypes, /*subtypeReduction*/ true );
1551
+ const type = <IntrinsicType & UnionType>getUnionType(trueFalseTypes);
1552
1552
type.flags |= TypeFlags.Boolean;
1553
1553
type.intrinsicName = "boolean";
1554
1554
return type;
@@ -5284,13 +5284,13 @@ namespace ts {
5284
5284
return type1.id - type2.id;
5285
5285
}
5286
5286
5287
- // We reduce the constituent type set to only include types that aren't subtypes of other types, unless
5288
- // the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on
5289
- // object identity . Subtype reduction is possible only when union types are known not to circularly
5290
- // reference themselves (as is the case with union types created by expression constructs such as array
5291
- // literals and the || and ?: operators). Named types can circularly reference themselves and therefore
5292
- // cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is
5293
- // a named type that circularly references itself.
5287
+ // We deduplicate the constituent types based on object identity. If the subtypeReduction flag is
5288
+ // specified we also reduce the constituent type set to only include types that aren't subtypes of
5289
+ // other types . Subtype reduction is expensive for large union types and is possible only when union
5290
+ // types are known not to circularly reference themselves (as is the case with union types created by
5291
+ // expression constructs such as array literals and the || and ?: operators). Named types can
5292
+ // circularly reference themselves and therefore cannot be deduplicated during their declaration.
5293
+ // For example, "type Item = string | (() => Item" is a named type that circularly references itself.
5294
5294
function getUnionType(types: Type[], subtypeReduction?: boolean, aliasSymbol?: Symbol, aliasTypeArguments?: Type[]): Type {
5295
5295
if (types.length === 0) {
5296
5296
return neverType;
@@ -7885,7 +7885,7 @@ namespace ts {
7885
7885
function getTypeWithDefault(type: Type, defaultExpression: Expression) {
7886
7886
if (defaultExpression) {
7887
7887
const defaultType = checkExpression(defaultExpression);
7888
- return getUnionType([getTypeWithFacts(type, TypeFacts.NEUndefined), defaultType], /*subtypeReduction*/ true );
7888
+ return getUnionType([getTypeWithFacts(type, TypeFacts.NEUndefined), defaultType]);
7889
7889
}
7890
7890
return type;
7891
7891
}
@@ -9125,7 +9125,7 @@ namespace ts {
9125
9125
for (let i = indexOfParameter; i < iife.arguments.length; i++) {
9126
9126
restTypes.push(getTypeOfExpression(iife.arguments[i]));
9127
9127
}
9128
- return createArrayType(getUnionType(restTypes, /*subtypeReduction*/ true ));
9128
+ return createArrayType(getUnionType(restTypes));
9129
9129
}
9130
9130
const links = getNodeLinks(iife);
9131
9131
const cached = links.resolvedSignature;
@@ -9328,7 +9328,7 @@ namespace ts {
9328
9328
}
9329
9329
}
9330
9330
}
9331
- return mappedTypes ? getUnionType(mappedTypes, /*subtypeReduction*/ true ) : mappedType;
9331
+ return mappedTypes ? getUnionType(mappedTypes) : mappedType;
9332
9332
}
9333
9333
9334
9334
function getTypeOfPropertyOfContextualType(type: Type, name: string) {
@@ -14619,7 +14619,7 @@ namespace ts {
14619
14619
case SyntaxKind.ClassDeclaration:
14620
14620
const classSymbol = getSymbolOfNode(node.parent);
14621
14621
const classConstructorType = getTypeOfSymbol(classSymbol);
14622
- expectedReturnType = getUnionType([classConstructorType, voidType], /*subtypeReduction*/ true );
14622
+ expectedReturnType = getUnionType([classConstructorType, voidType]);
14623
14623
break;
14624
14624
14625
14625
case SyntaxKind.Parameter:
@@ -14642,7 +14642,7 @@ namespace ts {
14642
14642
case SyntaxKind.SetAccessor:
14643
14643
const methodType = getTypeOfNode(node.parent);
14644
14644
const descriptorType = createTypedPropertyDescriptorType(methodType);
14645
- expectedReturnType = getUnionType([descriptorType, voidType], /*subtypeReduction*/ true );
14645
+ expectedReturnType = getUnionType([descriptorType, voidType]);
14646
14646
break;
14647
14647
}
14648
14648
0 commit comments