Skip to content

Commit 6b1c84e

Browse files
committed
Remove eager resolution of distributive conditional types
1 parent e98f9a6 commit 6b1c84e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/compiler/checker.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8969,9 +8969,6 @@ namespace ts {
89698969
if (checkType === wildcardType || extendsType === wildcardType) {
89708970
return wildcardType;
89718971
}
8972-
if (extendsType.flags & TypeFlags.AnyOrUnknown) {
8973-
return instantiateType(root.trueType, mapper);
8974-
}
89758972
// If this is a distributive conditional type and the check type is generic we need to defer
89768973
// resolution of the conditional type such that a later instantiation will properly distribute
89778974
// over union types.
@@ -8988,6 +8985,9 @@ namespace ts {
89888985
combinedMapper = combineTypeMappers(mapper, context);
89898986
}
89908987
if (!isDeferred) {
8988+
if (extendsType.flags & TypeFlags.AnyOrUnknown) {
8989+
return instantiateType(root.trueType, mapper);
8990+
}
89918991
// Return union of trueType and falseType for 'any' since it matches anything
89928992
if (checkType.flags & TypeFlags.Any) {
89938993
return getUnionType([instantiateType(root.trueType, combinedMapper || mapper), instantiateType(root.falseType, mapper)]);

0 commit comments

Comments
 (0)