@@ -19108,6 +19108,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
19108
19108
return isTypeRelatedTo(source, target, subtypeRelation);
19109
19109
}
19110
19110
19111
+ function isTypeStrictSubtypeOf(source: Type, target: Type): boolean {
19112
+ return isTypeRelatedTo(source, target, strictSubtypeRelation);
19113
+ }
19114
+
19111
19115
function isTypeAssignableTo(source: Type, target: Type): boolean {
19112
19116
return isTypeRelatedTo(source, target, assignableRelation);
19113
19117
}
@@ -27250,7 +27254,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
27250
27254
}
27251
27255
// We first attempt to filter the current type, narrowing constituents as appropriate and removing
27252
27256
// constituents that are unrelated to the candidate.
27253
- const isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf ;
27257
+ const isRelated = checkDerived ? isTypeDerivedFrom : isTypeStrictSubtypeOf ;
27254
27258
const keyPropertyName = type.flags & TypeFlags.Union ? getKeyPropertyName(type as UnionType) : undefined;
27255
27259
const narrowedType = mapType(candidate, c => {
27256
27260
// If a discriminant property is available, use that to reduce the type.
@@ -27260,9 +27264,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
27260
27264
// specific of the two. When t and c are related in both directions, we prefer c for type predicates
27261
27265
// because that is the asserted type, but t for `instanceof` because generics aren't reflected in
27262
27266
// prototype object types.
27263
- const directlyRelated = mapType(matching || type, checkDerived ?
27264
- t => isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType :
27265
- t => isTypeSubtypeOf(c, t) && !isTypeIdenticalTo(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType);
27267
+ const directlyRelated = mapType(matching || type, t => isRelated(t, c) ? t : isRelated(c, t) ? c : neverType);
27266
27268
// If no constituents are directly related, create intersections for any generic constituents that
27267
27269
// are related by constraint.
27268
27270
return directlyRelated.flags & TypeFlags.Never ?
@@ -27272,7 +27274,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
27272
27274
// If filtering produced a non-empty type, return that. Otherwise, pick the most specific of the two
27273
27275
// based on assignability, or as a last resort produce an intersection.
27274
27276
return !(narrowedType.flags & TypeFlags.Never) ? narrowedType :
27275
- isTypeSubtypeOf (candidate, type) ? candidate :
27277
+ isTypeStrictSubtypeOf (candidate, type) ? candidate :
27276
27278
isTypeAssignableTo(type, candidate) ? type :
27277
27279
isTypeAssignableTo(candidate, type) ? candidate :
27278
27280
getIntersectionType([type, candidate]);
0 commit comments