mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 11:24:49 -05:00
Replace subtype check in derivedness check with flags and structure checks (#27403)
* Replace subtype check in derivedness check with flags and structure checks * Remove now extraneous clause
This commit is contained in:
@@ -10616,9 +10616,9 @@ namespace ts {
|
||||
function isTypeDerivedFrom(source: Type, target: Type): boolean {
|
||||
return source.flags & TypeFlags.Union ? every((<UnionType>source).types, t => isTypeDerivedFrom(t, target)) :
|
||||
target.flags & TypeFlags.Union ? some((<UnionType>target).types, t => isTypeDerivedFrom(source, t)) :
|
||||
source.flags & TypeFlags.Primitive && !(target.flags & TypeFlags.Primitive) ? false :
|
||||
source.flags & TypeFlags.InstantiableNonPrimitive ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) :
|
||||
target === globalObjectType || target === globalFunctionType ? isTypeSubtypeOf(source, target) :
|
||||
target === globalObjectType ? !!(source.flags & (TypeFlags.Object | TypeFlags.NonPrimitive)) :
|
||||
target === globalFunctionType ? isFunctionObjectType(source as ObjectType) :
|
||||
hasBaseType(source, getTargetType(target));
|
||||
}
|
||||
|
||||
@@ -15371,7 +15371,7 @@ namespace ts {
|
||||
|
||||
// Check that right operand is a function type with a prototype property
|
||||
const rightType = getTypeOfExpression(expr.right);
|
||||
if (!isTypeSubtypeOf(rightType, globalFunctionType)) {
|
||||
if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user