@@ -8229,8 +8229,8 @@ namespace ts {
8229
8229
const inferredTypes = map(inferences, inference => getTypeFromInference(inference) || emptyObjectType);
8230
8230
combinedMapper = combineTypeMappers(mapper, createTypeMapper(root.inferTypeParameters, inferredTypes));
8231
8231
}
8232
- // Return union of trueType and falseType for any and never since they match anything
8233
- if (checkType.flags & TypeFlags.Any || (checkType.flags & TypeFlags.Never && !(extendsType.flags & TypeFlags.Never)) ) {
8232
+ // Return union of trueType and falseType for ' any' since it matches anything
8233
+ if (checkType.flags & TypeFlags.Any) {
8234
8234
return getUnionType([instantiateType(root.trueType, combinedMapper || mapper), instantiateType(root.falseType, mapper)]);
8235
8235
}
8236
8236
// Instantiate the extends type including inferences for 'infer T' type parameters
@@ -8911,7 +8911,7 @@ namespace ts {
8911
8911
if (root.isDistributive) {
8912
8912
const checkType = <TypeParameter>root.checkType;
8913
8913
const instantiatedType = mapper(checkType);
8914
- if (checkType !== instantiatedType && instantiatedType.flags & TypeFlags.Union) {
8914
+ if (checkType !== instantiatedType && instantiatedType.flags & ( TypeFlags.Union | TypeFlags.Never) ) {
8915
8915
return mapType(instantiatedType, t => getConditionalType(root, createReplacementMapper(checkType, t, mapper)));
8916
8916
}
8917
8917
}
@@ -12449,6 +12449,9 @@ namespace ts {
12449
12449
// is a union type, the mapping function is applied to each constituent type and a union
12450
12450
// of the resulting types is returned.
12451
12451
function mapType(type: Type, mapper: (t: Type) => Type, noReductions?: boolean): Type {
12452
+ if (type.flags & TypeFlags.Never) {
12453
+ return type;
12454
+ }
12452
12455
if (!(type.flags & TypeFlags.Union)) {
12453
12456
return mapper(type);
12454
12457
}
0 commit comments