@@ -88,7 +88,7 @@ module ts {
88
88
let undefinedType = createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsUndefinedOrNull, "undefined");
89
89
let nullType = createIntrinsicType(TypeFlags.Null | TypeFlags.ContainsUndefinedOrNull, "null");
90
90
let unknownType = createIntrinsicType(TypeFlags.Any, "unknown");
91
- let resolvingType = createIntrinsicType(TypeFlags.Any, "__resolving__ ");
91
+ let circularType = createIntrinsicType(TypeFlags.Any, "__circular__ ");
92
92
93
93
let emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
94
94
let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
@@ -3629,17 +3629,19 @@ module ts {
3629
3629
return type;
3630
3630
}
3631
3631
3632
+ // Subtype reduction is basically an optimization we do to avoid excessively large union types, which take longer
3633
+ // to process and look strange in quick info and error messages. Semantically there is no difference between the
3634
+ // reduced type and the type itself. So, when we detect a circularity we simply say that the reduced type is the
3635
+ // type itself.
3632
3636
function getReducedTypeOfUnionType(type: UnionType): Type {
3633
- // If union type was created without subtype reduction, perform the deferred reduction now. If a circularity
3634
- // is detected, simply use the type itself.
3635
3637
if (!type.reducedType) {
3636
- type.reducedType = resolvingType ;
3638
+ type.reducedType = circularType ;
3637
3639
let reducedType = getUnionType(type.types, /*noSubtypeReduction*/ false);
3638
- if (type.reducedType === resolvingType ) {
3640
+ if (type.reducedType === circularType ) {
3639
3641
type.reducedType = reducedType;
3640
3642
}
3641
3643
}
3642
- else if (type.reducedType === resolvingType ) {
3644
+ else if (type.reducedType === circularType ) {
3643
3645
type.reducedType = type;
3644
3646
}
3645
3647
return type.reducedType;
0 commit comments