Skip to content

Commit cedfd7e

Browse files
committed
Fix 'x instanceof ctor' where type of ctor is Function
1 parent e1c8dc2 commit cedfd7e

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15351,24 +15351,13 @@ namespace ts {
1535115351
}
1535215352

1535315353
if (!targetType) {
15354-
// Target type is type of construct signature
15355-
let constructSignatures: ReadonlyArray<Signature> | undefined;
15356-
if (getObjectFlags(rightType) & ObjectFlags.Interface) {
15357-
constructSignatures = resolveDeclaredMembers(<InterfaceType>rightType).declaredConstructSignatures;
15358-
}
15359-
else if (getObjectFlags(rightType) & ObjectFlags.Anonymous) {
15360-
constructSignatures = getSignaturesOfType(rightType, SignatureKind.Construct);
15361-
}
15362-
if (constructSignatures && constructSignatures.length) {
15363-
targetType = getUnionType(map(constructSignatures, signature => getReturnTypeOfSignature(getErasedSignature(signature))));
15364-
}
15354+
const constructSignatures = getSignaturesOfType(rightType, SignatureKind.Construct);
15355+
targetType = constructSignatures && constructSignatures.length ?
15356+
getUnionType(map(constructSignatures, signature => getReturnTypeOfSignature(getErasedSignature(signature)))) :
15357+
emptyObjectType;
1536515358
}
1536615359

15367-
if (targetType) {
15368-
return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
15369-
}
15370-
15371-
return type;
15360+
return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
1537215361
}
1537315362

1537415363
function getNarrowedType(type: Type, candidate: Type, assumeTrue: boolean, isRelated: (source: Type, target: Type) => boolean) {

0 commit comments

Comments
 (0)