mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-22 16:52:14 -06:00
Fix 'x instanceof ctor' where type of ctor is Function
This commit is contained in:
parent
e1c8dc2768
commit
cedfd7e08b
@ -15351,24 +15351,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (!targetType) {
|
||||
// Target type is type of construct signature
|
||||
let constructSignatures: ReadonlyArray<Signature> | undefined;
|
||||
if (getObjectFlags(rightType) & ObjectFlags.Interface) {
|
||||
constructSignatures = resolveDeclaredMembers(<InterfaceType>rightType).declaredConstructSignatures;
|
||||
}
|
||||
else if (getObjectFlags(rightType) & ObjectFlags.Anonymous) {
|
||||
constructSignatures = getSignaturesOfType(rightType, SignatureKind.Construct);
|
||||
}
|
||||
if (constructSignatures && constructSignatures.length) {
|
||||
targetType = getUnionType(map(constructSignatures, signature => getReturnTypeOfSignature(getErasedSignature(signature))));
|
||||
}
|
||||
const constructSignatures = getSignaturesOfType(rightType, SignatureKind.Construct);
|
||||
targetType = constructSignatures && constructSignatures.length ?
|
||||
getUnionType(map(constructSignatures, signature => getReturnTypeOfSignature(getErasedSignature(signature)))) :
|
||||
emptyObjectType;
|
||||
}
|
||||
|
||||
if (targetType) {
|
||||
return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
|
||||
}
|
||||
|
||||
return type;
|
||||
return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
|
||||
}
|
||||
|
||||
function getNarrowedType(type: Type, candidate: Type, assumeTrue: boolean, isRelated: (source: Type, target: Type) => boolean) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user