Skip to content

Commit 81326ac

Browse files
committed
Properly handle Object and Function types
1 parent 2a30aaf commit 81326ac

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8571,14 +8571,16 @@ namespace ts {
85718571
// An object type S is considered to be derived from an object type T if
85728572
// S is a union type and every constituent of S is derived from T,
85738573
// T is a union type and S is derived from at least one constituent of T, or
8574+
// T is one of the global types Object and Function and S is a subtype of T, or
85748575
// T occurs directly or indirectly in an 'extends' clause of S.
85758576
// Note that this check ignores type parameters and only considers the
85768577
// inheritance hierarchy.
85778578
function isTypeDerivedFrom(source: Type, target: Type): boolean {
85788579
return source.flags & TypeFlags.Union ? every((<UnionType>source).types, t => isTypeDerivedFrom(t, target)) :
85798580
target.flags & TypeFlags.Union ? some((<UnionType>target).types, t => isTypeDerivedFrom(source, t)) :
8581+
target === globalObjectType || target === globalFunctionType ? isTypeSubtypeOf(source, target) :
85808582
hasBaseType(source, getTargetType(target));
8581-
}
8583+
}
85828584

85838585
/**
85848586
* This is *not* a bi-directional relationship.

0 commit comments

Comments
 (0)