Skip to content

Commit 194680f

Browse files
committed
Addressing CR feedback
1 parent 9befdf6 commit 194680f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module ts {
8888
let undefinedType = createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsUndefinedOrNull, "undefined");
8989
let nullType = createIntrinsicType(TypeFlags.Null | TypeFlags.ContainsUndefinedOrNull, "null");
9090
let unknownType = createIntrinsicType(TypeFlags.Any, "unknown");
91-
let resolvingType = createIntrinsicType(TypeFlags.Any, "__resolving__");
91+
let circularType = createIntrinsicType(TypeFlags.Any, "__circular__");
9292

9393
let emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
9494
let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
@@ -3629,17 +3629,19 @@ module ts {
36293629
return type;
36303630
}
36313631

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.
36323636
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.
36353637
if (!type.reducedType) {
3636-
type.reducedType = resolvingType;
3638+
type.reducedType = circularType;
36373639
let reducedType = getUnionType(type.types, /*noSubtypeReduction*/ false);
3638-
if (type.reducedType === resolvingType) {
3640+
if (type.reducedType === circularType) {
36393641
type.reducedType = reducedType;
36403642
}
36413643
}
3642-
else if (type.reducedType === resolvingType) {
3644+
else if (type.reducedType === circularType) {
36433645
type.reducedType = type;
36443646
}
36453647
return type.reducedType;

0 commit comments

Comments
 (0)