MCPcopy Index your code
hub / github.com/nodejs/node / checkInstanceOfExpression

Function checkInstanceOfExpression

test/fixtures/snapshot/typescript.js:78592–78610  ·  view source on GitHub ↗
(left, right, leftType, rightType)

Source from the content-addressed store, hash-verified

78590 return (symbol.flags & 128 /* SymbolFlags.ConstEnum */) !== 0;
78591 }
78592 function checkInstanceOfExpression(left, right, leftType, rightType) {
78593 if (leftType === silentNeverType || rightType === silentNeverType) {
78594 return silentNeverType;
78595 }
78596 // TypeScript 1.0 spec (April 2014): 4.15.4
78597 // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type,
78598 // and the right operand to be of type Any, a subtype of the 'Function' interface type, or have a call or construct signature.
78599 // The result is always of the Boolean primitive type.
78600 // NOTE: do not raise error if leftType is unknown as related error was already reported
78601 if (!isTypeAny(leftType) &&
78602 allTypesAssignableToKind(leftType, 131068 /* TypeFlags.Primitive */)) {
78603 error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
78604 }
78605 // NOTE: do not raise error if right is unknown as related error was already reported
78606 if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
78607 error(right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type);
78608 }
78609 return booleanType;
78610 }
78611 function checkInExpression(left, right, leftType, rightType) {
78612 if (leftType === silentNeverType || rightType === silentNeverType) {
78613 return silentNeverType;

Callers 1

Calls 5

isTypeAnyFunction · 0.85
allTypesAssignableToKindFunction · 0.85
isTypeSubtypeOfFunction · 0.85
errorFunction · 0.70

Tested by

no test coverage detected