@@ -16782,7 +16782,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
16782
16782
// a subtype of just `A` or just `B`. When we encounter such a type parameter, we therefore check if the
16783
16783
// type parameter is a subtype of a union of all the other types.
16784
16784
if (source.flags & TypeFlags.TypeParameter && getBaseConstraintOrType(source).flags & TypeFlags.Union) {
16785
- if (isTypeStrictSubtypeOf (source, getUnionType(map(types, t => t === source ? neverType : t)))) {
16785
+ if (isTypeRelatedTo (source, getUnionType(map(types, t => t === source ? neverType : t)), strictSubtypeRelation )) {
16786
16786
orderedRemoveItemAt(types, i);
16787
16787
}
16788
16788
continue;
@@ -16816,7 +16816,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
16816
16816
}
16817
16817
}
16818
16818
if (
16819
- isTypeStrictSubtypeOf (source, target) && (
16819
+ isTypeRelatedTo (source, target, strictSubtypeRelation ) && (
16820
16820
!(getObjectFlags(getTargetType(source)) & ObjectFlags.Class) ||
16821
16821
!(getObjectFlags(getTargetType(target)) & ObjectFlags.Class) ||
16822
16822
isTypeDerivedFrom(source, target)
@@ -28042,7 +28042,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
28042
28042
// the constituent based on its type facts. We use the strict subtype relation because it treats `object`
28043
28043
// as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
28044
28044
// but are classified as "function" according to `typeof`.
28045
- isTypeStrictSubtypeOf (t, impliedType) ? hasTypeFacts(t, facts) ? t : neverType :
28045
+ isTypeRelatedTo (t, impliedType, strictSubtypeRelation ) ? hasTypeFacts(t, facts) ? t : neverType :
28046
28046
// We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
28047
28047
// type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
28048
28048
isTypeSubtypeOf(impliedType, t) ? impliedType :
@@ -28276,17 +28276,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
28276
28276
getIntersectionType([type, candidate]);
28277
28277
}
28278
28278
28279
- // function strictSubtypeImpliesSubtype(source: Type, target: Type) {
28280
- // const s = source.flags;
28281
- // const t = target.flags;
28282
- // if (
28283
- // !(t & TypeFlags.Unknown && !(s & TypeFlags.Any))
28284
- // || !(s & TypeFlags.Object && t & TypeFlags.NonPrimitive && !(isEmptyAnonymousObjectType(source) && !(getObjectFlags(source) & ObjectFlags.FreshLiteral)))
28285
- // ) return false;
28286
-
28287
- // return true;
28288
- // }
28289
-
28290
28279
function narrowTypeByCallExpression(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type {
28291
28280
if (hasMatchingArgument(callExpression, reference)) {
28292
28281
const signature = assumeTrue || !isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined;
0 commit comments