1
1
//// [arrayBestCommonTypes.ts]
2
- interface iface { }
3
- class base implements iface { }
4
- class base2 implements iface { }
5
- class derived extends base { }
6
-
7
-
8
- class f {
9
- public voidIfAny ( x : boolean , y ?: boolean ) : number ;
10
- public voidIfAny ( x : string , y ? : boolean ) : number ;
11
- public voidIfAny ( x : number , y ? : boolean ) : number ;
12
- public voidIfAny ( x : any , y = false ) : any { return null ; }
13
-
14
- public x ( ) {
15
- < number > ( this . voidIfAny ( [ 4 , 2 ] [ 0 ] ) ) ;
16
- < number > ( this . voidIfAny ( [ 4 , 2 , undefined ] [ 0 ] ) ) ;
17
- < number > ( this . voidIfAny ( [ undefined , 2 , 4 ] [ 0 ] ) ) ;
18
- < number > ( this . voidIfAny ( [ null , 2 , 4 ] [ 0 ] ) ) ;
19
- < number > ( this . voidIfAny ( [ 2 , 4 , null ] [ 0 ] ) ) ;
20
- < number > ( this . voidIfAny ( [ undefined , 4 , null ] [ 0 ] ) ) ;
21
-
22
- < number > ( this . voidIfAny ( [ '' , "q" ] [ 0 ] ) ) ;
23
- < number > ( this . voidIfAny ( [ '' , "q" , undefined ] [ 0 ] ) ) ;
24
- < number > ( this . voidIfAny ( [ undefined , "q" , '' ] [ 0 ] ) ) ;
25
- < number > ( this . voidIfAny ( [ null , "q" , '' ] [ 0 ] ) ) ;
26
- < number > ( this . voidIfAny ( [ "q" , '' , null ] [ 0 ] ) ) ;
27
- < number > ( this . voidIfAny ( [ undefined , '' , null ] [ 0 ] ) ) ;
28
-
29
- < number > ( this . voidIfAny ( [ [ 3 , 4 ] , [ null ] ] [ 0 ] [ 0 ] ) ) ;
30
-
31
-
32
- var t1 : { x : number ; y : base ; } [ ] = [ { x : 7 , y : new derived ( ) } , { x : 5 , y : new base ( ) } ] ;
33
- var t2 : { x : boolean ; y : base ; } [ ] = [ { x : true , y : new derived ( ) } , { x : false , y : new base ( ) } ] ;
34
- var t3 : { x : string ; y : base ; } [ ] = [ { x : undefined , y : new base ( ) } , { x : '' , y : new derived ( ) } ] ;
35
-
36
- var anyObj : any = null ;
37
- // Order matters here so test all the variants
38
- var a1 = [ { x : 0 , y : 'a' } , { x : 'a' , y : 'a' } , { x : anyObj , y : 'a' } ] ;
39
- var a2 = [ { x : anyObj , y : 'a' } , { x : 0 , y : 'a' } , { x : 'a' , y : 'a' } ] ;
40
- var a3 = [ { x : 0 , y : 'a' } , { x : anyObj , y : 'a' } , { x : 'a' , y : 'a' } ] ;
41
-
42
- var ifaceObj : iface = null ;
43
- var baseObj = new base ( ) ;
44
- var base2Obj = new base2 ( ) ;
45
-
46
- var b1 = [ baseObj , base2Obj , ifaceObj ] ;
47
- var b2 = [ base2Obj , baseObj , ifaceObj ] ;
48
- var b3 = [ baseObj , ifaceObj , base2Obj ] ;
49
- var b4 = [ ifaceObj , baseObj , base2Obj ] ;
2
+ module EmptyTypes {
3
+ interface iface { }
4
+ class base implements iface { }
5
+ class base2 implements iface { }
6
+ class derived extends base { }
7
+
8
+
9
+ class f {
10
+ public voidIfAny ( x : boolean , y ?: boolean ) : number ;
11
+ public voidIfAny ( x : string , y ? : boolean ) : number ;
12
+ public voidIfAny ( x : number , y ? : boolean ) : number ;
13
+ public voidIfAny ( x : any , y = false ) : any { return null ; }
14
+
15
+ public x ( ) {
16
+ < number > ( this . voidIfAny ( [ 4 , 2 ] [ 0 ] ) ) ;
17
+ < number > ( this . voidIfAny ( [ 4 , 2 , undefined ] [ 0 ] ) ) ;
18
+ < number > ( this . voidIfAny ( [ undefined , 2 , 4 ] [ 0 ] ) ) ;
19
+ < number > ( this . voidIfAny ( [ null , 2 , 4 ] [ 0 ] ) ) ;
20
+ < number > ( this . voidIfAny ( [ 2 , 4 , null ] [ 0 ] ) ) ;
21
+ < number > ( this . voidIfAny ( [ undefined , 4 , null ] [ 0 ] ) ) ;
22
+
23
+ < number > ( this . voidIfAny ( [ '' , "q" ] [ 0 ] ) ) ;
24
+ < number > ( this . voidIfAny ( [ '' , "q" , undefined ] [ 0 ] ) ) ;
25
+ < number > ( this . voidIfAny ( [ undefined , "q" , '' ] [ 0 ] ) ) ;
26
+ < number > ( this . voidIfAny ( [ null , "q" , '' ] [ 0 ] ) ) ;
27
+ < number > ( this . voidIfAny ( [ "q" , '' , null ] [ 0 ] ) ) ;
28
+ < number > ( this . voidIfAny ( [ undefined , '' , null ] [ 0 ] ) ) ;
29
+
30
+ < number > ( this . voidIfAny ( [ [ 3 , 4 ] , [ null ] ] [ 0 ] [ 0 ] ) ) ;
31
+
32
+
33
+ var t1 : { x : number ; y : base ; } [ ] = [ { x : 7 , y : new derived ( ) } , { x : 5 , y : new base ( ) } ] ;
34
+ var t2 : { x : boolean ; y : base ; } [ ] = [ { x : true , y : new derived ( ) } , { x : false , y : new base ( ) } ] ;
35
+ var t3 : { x : string ; y : base ; } [ ] = [ { x : undefined , y : new base ( ) } , { x : '' , y : new derived ( ) } ] ;
36
+
37
+ var anyObj : any = null ;
38
+ // Order matters here so test all the variants
39
+ var a1 = [ { x : 0 , y : 'a' } , { x : 'a' , y : 'a' } , { x : anyObj , y : 'a' } ] ;
40
+ var a2 = [ { x : anyObj , y : 'a' } , { x : 0 , y : 'a' } , { x : 'a' , y : 'a' } ] ;
41
+ var a3 = [ { x : 0 , y : 'a' } , { x : anyObj , y : 'a' } , { x : 'a' , y : 'a' } ] ;
42
+
43
+ var ifaceObj : iface = null ;
44
+ var baseObj = new base ( ) ;
45
+ var base2Obj = new base2 ( ) ;
46
+
47
+ var b1 = [ baseObj , base2Obj , ifaceObj ] ;
48
+ var b2 = [ base2Obj , baseObj , ifaceObj ] ;
49
+ var b3 = [ baseObj , ifaceObj , base2Obj ] ;
50
+ var b4 = [ ifaceObj , baseObj , base2Obj ] ;
51
+ }
50
52
}
51
53
}
52
54
55
+ module NonEmptyTypes {
56
+ interface iface { x : string ; }
57
+ class base implements iface { x : string ; y : string ; }
58
+ class base2 implements iface { x : string ; z : string ; }
59
+ class derived extends base { a : string ; }
60
+
61
+
62
+ class f {
63
+ public voidIfAny ( x : boolean , y ? : boolean ) : number ;
64
+ public voidIfAny ( x : string , y ? : boolean ) : number ;
65
+ public voidIfAny ( x : number , y ? : boolean ) : number ;
66
+ public voidIfAny ( x : any , y = false ) : any { return null ; }
67
+
68
+ public x ( ) {
69
+ < number > ( this . voidIfAny ( [ 4 , 2 ] [ 0 ] ) ) ;
70
+ < number > ( this . voidIfAny ( [ 4 , 2 , undefined ] [ 0 ] ) ) ;
71
+ < number > ( this . voidIfAny ( [ undefined , 2 , 4 ] [ 0 ] ) ) ;
72
+ < number > ( this . voidIfAny ( [ null , 2 , 4 ] [ 0 ] ) ) ;
73
+ < number > ( this . voidIfAny ( [ 2 , 4 , null ] [ 0 ] ) ) ;
74
+ < number > ( this . voidIfAny ( [ undefined , 4 , null ] [ 0 ] ) ) ;
75
+
76
+ < number > ( this . voidIfAny ( [ '' , "q" ] [ 0 ] ) ) ;
77
+ < number > ( this . voidIfAny ( [ '' , "q" , undefined ] [ 0 ] ) ) ;
78
+ < number > ( this . voidIfAny ( [ undefined , "q" , '' ] [ 0 ] ) ) ;
79
+ < number > ( this . voidIfAny ( [ null , "q" , '' ] [ 0 ] ) ) ;
80
+ < number > ( this . voidIfAny ( [ "q" , '' , null ] [ 0 ] ) ) ;
81
+ < number > ( this . voidIfAny ( [ undefined , '' , null ] [ 0 ] ) ) ;
82
+
83
+ < number > ( this . voidIfAny ( [ [ 3 , 4 ] , [ null ] ] [ 0 ] [ 0 ] ) ) ;
84
+
85
+
86
+ var t1 : { x : number ; y : base ; } [ ] = [ { x : 7 , y : new derived ( ) } , { x : 5 , y : new base ( ) } ] ;
87
+ var t2 : { x : boolean ; y : base ; } [ ] = [ { x : true , y : new derived ( ) } , { x : false , y : new base ( ) } ] ;
88
+ var t3 : { x : string ; y : base ; } [ ] = [ { x : undefined , y : new base ( ) } , { x : '' , y : new derived ( ) } ] ;
89
+
90
+ var anyObj : any = null ;
91
+ // Order matters here so test all the variants
92
+ var a1 = [ { x : 0 , y : 'a' } , { x : 'a' , y : 'a' } , { x : anyObj , y : 'a' } ] ;
93
+ var a2 = [ { x : anyObj , y : 'a' } , { x : 0 , y : 'a' } , { x : 'a' , y : 'a' } ] ;
94
+ var a3 = [ { x : 0 , y : 'a' } , { x : anyObj , y : 'a' } , { x : 'a' , y : 'a' } ] ;
95
+
96
+ var ifaceObj : iface = null ;
97
+ var baseObj = new base ( ) ;
98
+ var base2Obj = new base2 ( ) ;
99
+
100
+ var b1 = [ baseObj , base2Obj , ifaceObj ] ;
101
+ var b2 = [ base2Obj , baseObj , ifaceObj ] ;
102
+ var b3 = [ baseObj , ifaceObj , base2Obj ] ;
103
+ var b4 = [ ifaceObj , baseObj , base2Obj ] ;
104
+ }
105
+ }
106
+ }
53
107
54
108
55
109
@@ -60,59 +114,121 @@ var __extends = this.__extends || function (d, b) {
60
114
__ . prototype = b . prototype ;
61
115
d . prototype = new __ ( ) ;
62
116
} ;
63
- var base = ( function ( ) {
64
- function base ( ) {
65
- }
66
- return base ;
67
- } ) ( ) ;
68
- var base2 = ( function ( ) {
69
- function base2 ( ) {
70
- }
71
- return base2 ;
72
- } ) ( ) ;
73
- var derived = ( function ( _super ) {
74
- __extends ( derived , _super ) ;
75
- function derived ( ) {
76
- _super . apply ( this , arguments ) ;
77
- }
78
- return derived ;
79
- } ) ( base ) ;
80
- var f = ( function ( ) {
81
- function f ( ) {
82
- }
83
- f . prototype . voidIfAny = function ( x , y ) {
84
- if ( y === void 0 ) { y = false ; }
85
- return null ;
86
- } ;
87
- f . prototype . x = function ( ) {
88
- ( this . voidIfAny ( [ 4 , 2 ] [ 0 ] ) ) ;
89
- ( this . voidIfAny ( [ 4 , 2 , undefined ] [ 0 ] ) ) ;
90
- ( this . voidIfAny ( [ undefined , 2 , 4 ] [ 0 ] ) ) ;
91
- ( this . voidIfAny ( [ null , 2 , 4 ] [ 0 ] ) ) ;
92
- ( this . voidIfAny ( [ 2 , 4 , null ] [ 0 ] ) ) ;
93
- ( this . voidIfAny ( [ undefined , 4 , null ] [ 0 ] ) ) ;
94
- ( this . voidIfAny ( [ '' , "q" ] [ 0 ] ) ) ;
95
- ( this . voidIfAny ( [ '' , "q" , undefined ] [ 0 ] ) ) ;
96
- ( this . voidIfAny ( [ undefined , "q" , '' ] [ 0 ] ) ) ;
97
- ( this . voidIfAny ( [ null , "q" , '' ] [ 0 ] ) ) ;
98
- ( this . voidIfAny ( [ "q" , '' , null ] [ 0 ] ) ) ;
99
- ( this . voidIfAny ( [ undefined , '' , null ] [ 0 ] ) ) ;
100
- ( this . voidIfAny ( [ [ 3 , 4 ] , [ null ] ] [ 0 ] [ 0 ] ) ) ;
101
- var t1 = [ { x : 7 , y : new derived ( ) } , { x : 5 , y : new base ( ) } ] ;
102
- var t2 = [ { x : true , y : new derived ( ) } , { x : false , y : new base ( ) } ] ;
103
- var t3 = [ { x : undefined , y : new base ( ) } , { x : '' , y : new derived ( ) } ] ;
104
- var anyObj = null ;
105
- // Order matters here so test all the variants
106
- var a1 = [ { x : 0 , y : 'a' } , { x : 'a' , y : 'a' } , { x : anyObj , y : 'a' } ] ;
107
- var a2 = [ { x : anyObj , y : 'a' } , { x : 0 , y : 'a' } , { x : 'a' , y : 'a' } ] ;
108
- var a3 = [ { x : 0 , y : 'a' } , { x : anyObj , y : 'a' } , { x : 'a' , y : 'a' } ] ;
109
- var ifaceObj = null ;
110
- var baseObj = new base ( ) ;
111
- var base2Obj = new base2 ( ) ;
112
- var b1 = [ baseObj , base2Obj , ifaceObj ] ;
113
- var b2 = [ base2Obj , baseObj , ifaceObj ] ;
114
- var b3 = [ baseObj , ifaceObj , base2Obj ] ;
115
- var b4 = [ ifaceObj , baseObj , base2Obj ] ;
116
- } ;
117
- return f ;
118
- } ) ( ) ;
117
+ var EmptyTypes ;
118
+ ( function ( EmptyTypes ) {
119
+ var base = ( function ( ) {
120
+ function base ( ) {
121
+ }
122
+ return base ;
123
+ } ) ( ) ;
124
+ var base2 = ( function ( ) {
125
+ function base2 ( ) {
126
+ }
127
+ return base2 ;
128
+ } ) ( ) ;
129
+ var derived = ( function ( _super ) {
130
+ __extends ( derived , _super ) ;
131
+ function derived ( ) {
132
+ _super . apply ( this , arguments ) ;
133
+ }
134
+ return derived ;
135
+ } ) ( base ) ;
136
+ var f = ( function ( ) {
137
+ function f ( ) {
138
+ }
139
+ f . prototype . voidIfAny = function ( x , y ) {
140
+ if ( y === void 0 ) { y = false ; }
141
+ return null ;
142
+ } ;
143
+ f . prototype . x = function ( ) {
144
+ ( this . voidIfAny ( [ 4 , 2 ] [ 0 ] ) ) ;
145
+ ( this . voidIfAny ( [ 4 , 2 , undefined ] [ 0 ] ) ) ;
146
+ ( this . voidIfAny ( [ undefined , 2 , 4 ] [ 0 ] ) ) ;
147
+ ( this . voidIfAny ( [ null , 2 , 4 ] [ 0 ] ) ) ;
148
+ ( this . voidIfAny ( [ 2 , 4 , null ] [ 0 ] ) ) ;
149
+ ( this . voidIfAny ( [ undefined , 4 , null ] [ 0 ] ) ) ;
150
+ ( this . voidIfAny ( [ '' , "q" ] [ 0 ] ) ) ;
151
+ ( this . voidIfAny ( [ '' , "q" , undefined ] [ 0 ] ) ) ;
152
+ ( this . voidIfAny ( [ undefined , "q" , '' ] [ 0 ] ) ) ;
153
+ ( this . voidIfAny ( [ null , "q" , '' ] [ 0 ] ) ) ;
154
+ ( this . voidIfAny ( [ "q" , '' , null ] [ 0 ] ) ) ;
155
+ ( this . voidIfAny ( [ undefined , '' , null ] [ 0 ] ) ) ;
156
+ ( this . voidIfAny ( [ [ 3 , 4 ] , [ null ] ] [ 0 ] [ 0 ] ) ) ;
157
+ var t1 = [ { x : 7 , y : new derived ( ) } , { x : 5 , y : new base ( ) } ] ;
158
+ var t2 = [ { x : true , y : new derived ( ) } , { x : false , y : new base ( ) } ] ;
159
+ var t3 = [ { x : undefined , y : new base ( ) } , { x : '' , y : new derived ( ) } ] ;
160
+ var anyObj = null ;
161
+ // Order matters here so test all the variants
162
+ var a1 = [ { x : 0 , y : 'a' } , { x : 'a' , y : 'a' } , { x : anyObj , y : 'a' } ] ;
163
+ var a2 = [ { x : anyObj , y : 'a' } , { x : 0 , y : 'a' } , { x : 'a' , y : 'a' } ] ;
164
+ var a3 = [ { x : 0 , y : 'a' } , { x : anyObj , y : 'a' } , { x : 'a' , y : 'a' } ] ;
165
+ var ifaceObj = null ;
166
+ var baseObj = new base ( ) ;
167
+ var base2Obj = new base2 ( ) ;
168
+ var b1 = [ baseObj , base2Obj , ifaceObj ] ;
169
+ var b2 = [ base2Obj , baseObj , ifaceObj ] ;
170
+ var b3 = [ baseObj , ifaceObj , base2Obj ] ;
171
+ var b4 = [ ifaceObj , baseObj , base2Obj ] ;
172
+ } ;
173
+ return f ;
174
+ } ) ( ) ;
175
+ } ) ( EmptyTypes || ( EmptyTypes = { } ) ) ;
176
+ var NonEmptyTypes ;
177
+ ( function ( NonEmptyTypes ) {
178
+ var base = ( function ( ) {
179
+ function base ( ) {
180
+ }
181
+ return base ;
182
+ } ) ( ) ;
183
+ var base2 = ( function ( ) {
184
+ function base2 ( ) {
185
+ }
186
+ return base2 ;
187
+ } ) ( ) ;
188
+ var derived = ( function ( _super ) {
189
+ __extends ( derived , _super ) ;
190
+ function derived ( ) {
191
+ _super . apply ( this , arguments ) ;
192
+ }
193
+ return derived ;
194
+ } ) ( base ) ;
195
+ var f = ( function ( ) {
196
+ function f ( ) {
197
+ }
198
+ f . prototype . voidIfAny = function ( x , y ) {
199
+ if ( y === void 0 ) { y = false ; }
200
+ return null ;
201
+ } ;
202
+ f . prototype . x = function ( ) {
203
+ ( this . voidIfAny ( [ 4 , 2 ] [ 0 ] ) ) ;
204
+ ( this . voidIfAny ( [ 4 , 2 , undefined ] [ 0 ] ) ) ;
205
+ ( this . voidIfAny ( [ undefined , 2 , 4 ] [ 0 ] ) ) ;
206
+ ( this . voidIfAny ( [ null , 2 , 4 ] [ 0 ] ) ) ;
207
+ ( this . voidIfAny ( [ 2 , 4 , null ] [ 0 ] ) ) ;
208
+ ( this . voidIfAny ( [ undefined , 4 , null ] [ 0 ] ) ) ;
209
+ ( this . voidIfAny ( [ '' , "q" ] [ 0 ] ) ) ;
210
+ ( this . voidIfAny ( [ '' , "q" , undefined ] [ 0 ] ) ) ;
211
+ ( this . voidIfAny ( [ undefined , "q" , '' ] [ 0 ] ) ) ;
212
+ ( this . voidIfAny ( [ null , "q" , '' ] [ 0 ] ) ) ;
213
+ ( this . voidIfAny ( [ "q" , '' , null ] [ 0 ] ) ) ;
214
+ ( this . voidIfAny ( [ undefined , '' , null ] [ 0 ] ) ) ;
215
+ ( this . voidIfAny ( [ [ 3 , 4 ] , [ null ] ] [ 0 ] [ 0 ] ) ) ;
216
+ var t1 = [ { x : 7 , y : new derived ( ) } , { x : 5 , y : new base ( ) } ] ;
217
+ var t2 = [ { x : true , y : new derived ( ) } , { x : false , y : new base ( ) } ] ;
218
+ var t3 = [ { x : undefined , y : new base ( ) } , { x : '' , y : new derived ( ) } ] ;
219
+ var anyObj = null ;
220
+ // Order matters here so test all the variants
221
+ var a1 = [ { x : 0 , y : 'a' } , { x : 'a' , y : 'a' } , { x : anyObj , y : 'a' } ] ;
222
+ var a2 = [ { x : anyObj , y : 'a' } , { x : 0 , y : 'a' } , { x : 'a' , y : 'a' } ] ;
223
+ var a3 = [ { x : 0 , y : 'a' } , { x : anyObj , y : 'a' } , { x : 'a' , y : 'a' } ] ;
224
+ var ifaceObj = null ;
225
+ var baseObj = new base ( ) ;
226
+ var base2Obj = new base2 ( ) ;
227
+ var b1 = [ baseObj , base2Obj , ifaceObj ] ;
228
+ var b2 = [ base2Obj , baseObj , ifaceObj ] ;
229
+ var b3 = [ baseObj , ifaceObj , base2Obj ] ;
230
+ var b4 = [ ifaceObj , baseObj , base2Obj ] ;
231
+ } ;
232
+ return f ;
233
+ } ) ( ) ;
234
+ } ) ( NonEmptyTypes || ( NonEmptyTypes = { } ) ) ;
0 commit comments