Skip to content

Commit 9a2846e

Browse files
unknownunknown
authored andcommitted
Addressing CR feedback
1 parent f33acf8 commit 9a2846e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/compiler/checker.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)