Skip to content

Commit 9598acd

Browse files
committed
Properly handle 'any' and 'never' as conditional check type
1 parent 15baf0e commit 9598acd

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/compiler/checker.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8415,6 +8415,10 @@ namespace ts {
84158415
if (checkType.flags & TypeFlags.Union) {
84168416
return getUnionType(map((<UnionType>checkType).types, t => getConditionalType(t, extendsType, mapper, trueType, falseType)));
84178417
}
8418+
// Return union of trueType and falseType for any and never since they match anything
8419+
if (checkType.flags & (TypeFlags.Any | TypeFlags.Never)) {
8420+
return getUnionType([instantiateType(trueType, mapper), instantiateType(falseType, mapper)]);
8421+
}
84188422
// Return trueType for a definitely true extends check
84198423
if (isTypeAssignableTo(checkType, extendsType)) {
84208424
return instantiateType(trueType, mapper);

0 commit comments

Comments
 (0)