mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fix instanceof use with Symbol.hasInstance in conjunction with union/intersection (#57602)
This commit is contained in:
@@ -37974,11 +37974,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
*/
|
||||
function getSymbolHasInstanceMethodOfObjectType(type: Type) {
|
||||
const hasInstancePropertyName = getPropertyNameForKnownSymbolName("hasInstance");
|
||||
const hasInstanceProperty = getPropertyOfObjectType(type, hasInstancePropertyName);
|
||||
if (hasInstanceProperty) {
|
||||
const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
|
||||
if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, SignatureKind.Call).length !== 0) {
|
||||
return hasInstancePropertyType;
|
||||
if (allTypesAssignableToKind(type, TypeFlags.NonPrimitive)) {
|
||||
const hasInstanceProperty = getPropertyOfType(type, hasInstancePropertyName);
|
||||
if (hasInstanceProperty) {
|
||||
const hasInstancePropertyType = getTypeOfSymbol(hasInstanceProperty);
|
||||
if (hasInstancePropertyType && getSignaturesOfType(hasInstancePropertyType, SignatureKind.Call).length !== 0) {
|
||||
return hasInstancePropertyType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user