File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3584,7 +3584,8 @@ module ts {
35843584
35853585 // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag
35863586 // is true when creating a union type from a type node and when instantiating a union type. In both of those
3587- // cases subtype reduction has to be deferred to properly support recursive union types.
3587+ // cases subtype reduction has to be deferred to properly support recursive union types. For example, a
3588+ // type alias of the form "type Item = string | (() => Item)" cannot be reduced during its declaration.
35883589 function getUnionType(types: Type[], noSubtypeReduction?: boolean): Type {
35893590 if (types.length === 0) {
35903591 return emptyObjectType;
@@ -3615,8 +3616,9 @@ module ts {
36153616 }
36163617
36173618 function getReducedTypeOfUnionType(type: UnionType): Type {
3619+ // If union type was created without subtype reduction, perform the deferred reduction now
36183620 if (!type.reducedType) {
3619- type.reducedType = getUnionType(type.types);
3621+ type.reducedType = getUnionType(type.types, /*noSubtypeReduction*/ false );
36203622 }
36213623 return type.reducedType;
36223624 }
You can’t perform that action at this time.
0 commit comments