File: inOperatorWithValidOperands.js

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (60 lines) | stat: -rw-r--r-- 1,251 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//// [inOperatorWithValidOperands.ts]
var x: any;

// valid left operands
// the left operand is required to be of type Any, the String primitive type, or the Number primitive type
var a1: string;
var a2: number;

var ra1 = x in x;
var ra2 = a1 in x;
var ra3 = a2 in x;
var ra4 = '' in x;
var ra5 = 0 in x;

// valid right operands
// the right operand is required to be of type Any, an object type, or a type parameter type
var b1: {};

var rb1 = x in b1;
var rb2 = x in {};

function foo<T>(t: T) {
    var rb3 = x in t;
}

interface X { x: number }
interface Y { y: number }

var c1: X | Y;
var c2: X;
var c3: Y;

var rc1 = x in c1;
var rc2 = x in (c2 || c3);


//// [inOperatorWithValidOperands.js]
var x;
// valid left operands
// the left operand is required to be of type Any, the String primitive type, or the Number primitive type
var a1;
var a2;
var ra1 = x in x;
var ra2 = a1 in x;
var ra3 = a2 in x;
var ra4 = '' in x;
var ra5 = 0 in x;
// valid right operands
// the right operand is required to be of type Any, an object type, or a type parameter type
var b1;
var rb1 = x in b1;
var rb2 = x in {};
function foo(t) {
    var rb3 = x in t;
}
var c1;
var c2;
var c3;
var rc1 = x in c1;
var rc2 = x in (c2 || c3);