mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
do not report cascading errors in instanceof operator
This commit is contained in:
@@ -4935,10 +4935,12 @@ module ts {
|
||||
// The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type,
|
||||
// and the right operand to be of type Any or a subtype of the 'Function' interface type.
|
||||
// The result is always of the Boolean primitive type.
|
||||
if (!isTypeAnyTypeObjectTypeOrTypeParameter(leftType)) {
|
||||
// NOTE: do not raise error is leftType is unknown as related error was already reported
|
||||
if (leftType !== unknownType && !isTypeAnyTypeObjectTypeOrTypeParameter(leftType)) {
|
||||
error(node.left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
if (rightType !== anyType && !isTypeSubtypeOf(rightType, globalFunctionType)) {
|
||||
// NOTE: do not raise error is right is unknown as related error was already reported
|
||||
if (rightType !== unknownType && rightType !== anyType && !isTypeSubtypeOf(rightType, globalFunctionType)) {
|
||||
error(node.right, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type);
|
||||
}
|
||||
return booleanType;
|
||||
|
||||
Reference in New Issue
Block a user