TypeScript/tests/baselines/reference/instanceofOperator.errors.txt

42 lines
2.4 KiB
Plaintext
Raw Normal View History

tests/cases/compiler/instanceofOperator.ts(12,5): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
tests/cases/compiler/instanceofOperator.ts(15,20): error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
tests/cases/compiler/instanceofOperator.ts(16,23): error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
tests/cases/compiler/instanceofOperator.ts(19,5): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
tests/cases/compiler/instanceofOperator.ts(21,5): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
==== tests/cases/compiler/instanceofOperator.ts (5 errors) ====
2014-07-13 01:04:16 +02:00
// Spec:
// The instanceof operator requires the left operand to be of type Any or an object 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.
module test {
class Object { }
var obj: Object;
2014-07-13 01:04:16 +02:00
4 instanceof null;
~
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
2014-07-13 01:04:16 +02:00
// Error and should be error
obj instanceof 4;
~
!!! error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
Object instanceof obj;
~~~
!!! error TS2359: The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.
2014-07-13 01:04:16 +02:00
// Error on left hand side
null instanceof null;
~~~~
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
obj instanceof Object;
undefined instanceof undefined;
~~~~~~~~~
!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
}
2014-07-13 01:04:16 +02:00