TypeScript/tests/baselines/reference/instanceofOperatorWithInvalidOperands.errors.txt
2014-07-12 17:30:19 -07:00

89 lines
4.4 KiB
Plaintext

==== tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidOperands.ts (21 errors) ====
class C {
foo() { }
}
var x: any;
// invalid left operand
// the left operand is required to be of type Any, an object type, or a type parameter type
var a1: number;
var a2: boolean;
var a3: string;
var a4: void;
var ra1 = a1 instanceof x;
~~
!!! The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
var ra2 = a2 instanceof x;
~~
!!! The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
var ra3 = a3 instanceof x;
~~
!!! The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
var ra4 = a4 instanceof x;
~~
!!! The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
var ra5 = 0 instanceof x;
~
!!! The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
var ra6 = true instanceof x;
~~~~
!!! The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
var ra7 = '' instanceof x;
~~
!!! The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
var ra8 = null instanceof x;
~~~~
!!! The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
var ra9 = undefined instanceof x;
~~~~~~~~~
!!! The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
// invalid right operand
// the right operand to be of type Any or a subtype of the 'Function' interface type
var b1: number;
var b2: boolean;
var b3: string;
var b4: void;
var o1: {};
var o2: Object;
var o3: C;
var rb1 = x instanceof b1;
~~
!!! The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
var rb2 = x instanceof b2;
~~
!!! The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
var rb3 = x instanceof b3;
~~
!!! The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
var rb4 = x instanceof b4;
~~
!!! The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
var rb5 = x instanceof 0;
~
!!! The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
var rb6 = x instanceof true;
~~~~
!!! The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
var rb7 = x instanceof '';
~~
!!! The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
var rb8 = x instanceof o1;
~~
!!! The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
var rb9 = x instanceof o2;
~~
!!! The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
var rb10 = x instanceof o3;
~~
!!! The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
// both operands are invalid
var rc1 = '' instanceof {};
~~
!!! The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
~~
!!! The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.