TypeScript/tests/cases/compiler/instanceofOperator.ts

24 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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;
4 instanceof null;
// Error and should be error
obj instanceof 4;
Object instanceof obj;
// Error on left hand side
null instanceof null;
obj instanceof Object;
undefined instanceof undefined;
}