File: subtypesOfTypeParameterWithConstraints.js

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (408 lines) | stat: -rw-r--r-- 10,894 bytes parent folder | download
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
//// [subtypesOfTypeParameterWithConstraints.ts]
// checking whether other types are subtypes of type parameters with constraints

class C3<T> {
    foo: T;
}

class D1<T extends U, U> extends C3<T> {
    [x: string]: T;
    foo: T; // ok
}

class D2<T extends U, U> extends C3<U> {
    [x: string]: U;
    foo: T; // ok
}

class D3<T extends U, U> extends C3<T> {
    [x: string]: T;
    foo: U; // error
}

class D4<T extends U, U> extends C3<U> {
    [x: string]: U;
    foo: U; // ok
}


// V > U > T
// test if T is subtype of T, U, V
// should all work
class D5<T extends U, U extends V, V> extends C3<T> {
    [x: string]: T;
    foo: T; // ok
}

class D6<T extends U, U extends V, V> extends C3<U> {
    [x: string]: U;
    foo: T;
}

class D7<T extends U, U extends V, V> extends C3<V> {
    [x: string]: V;
    foo: T; // ok
}

// test if U is a subtype of T, U, V
// only a subtype of V and itself
class D8<T extends U, U extends V, V> extends C3<T> {
    [x: string]: T;
    foo: U; // error
}

class D9<T extends U, U extends V, V> extends C3<U> {
    [x: string]: U;
    foo: U; // ok
}

class D10<T extends U, U extends V, V> extends C3<V> {
    [x: string]: V;
    foo: U; // ok
}

// test if V is a subtype of T, U, V
// only a subtype of itself
class D11<T extends U, U extends V, V> extends C3<T> {
    [x: string]: T;
    foo: V; // error
}

class D12<T extends U, U extends V, V> extends C3<U> {
    [x: string]: U;
    foo: V; // error
}

class D13<T extends U, U extends V, V> extends C3<V> {
    [x: string]: V;
    foo: V; // ok
}

// Date > V > U > T
// test if T is subtype of T, U, V, Date
// should all work
class D14<T extends U, U extends V, V extends Date> extends C3<Date> {
    [x: string]: Date;
    foo: T; // ok
}

class D15<T extends U, U extends V, V extends Date> extends C3<T> {
    [x: string]: T;
    foo: T; // ok
}

class D16<T extends U, U extends V, V extends Date> extends C3<U> {
    [x: string]: U;
    foo: T;
}

class D17<T extends U, U extends V, V extends Date> extends C3<V> {
    [x: string]: V;
    foo: T;
}

// test if U is a subtype of T, U, V, Date
// only a subtype of V, Date and itself
class D18<T extends U, U extends V, V extends Date> extends C3<Date> {
    [x: string]: Date;
    foo: T; // ok
}

class D19<T extends U, U extends V, V extends Date> extends C3<T> {
    [x: string]: T;
    foo: U; // error
}

class D20<T extends U, U extends V, V extends Date> extends C3<U> {
    [x: string]: U;
    foo: U; // ok
}

class D21<T extends U, U extends V, V extends Date> extends C3<V> {
    [x: string]: V;
    foo: U;
}

// test if V is a subtype of T, U, V, Date
// only a subtype of itself and Date
class D22<T extends U, U extends V, V extends Date> extends C3<Date> {
    [x: string]: Date;
    foo: T; // ok
}

class D23<T extends U, U extends V, V extends Date> extends C3<T> {
    [x: string]: T;
    foo: V; // error
}

class D24<T extends U, U extends V, V extends Date> extends C3<U> {
    [x: string]: U;
    foo: V; // error
}

class D25<T extends U, U extends V, V extends Date> extends C3<V> {
    [x: string]: V;
    foo: V; // ok
}

// test if Date is a subtype of T, U, V, Date
// only a subtype of itself
class D26<T extends U, U extends V, V extends Date> extends C3<Date> {
    [x: string]: Date;
    foo: Date; // ok
}

class D27<T extends U, U extends V, V extends Date> extends C3<T> {
    [x: string]: T;
    foo: Date; // error
}

class D28<T extends U, U extends V, V extends Date> extends C3<U> {
    [x: string]: U;
    foo: Date; // error
}

class D29<T extends U, U extends V, V extends Date> extends C3<V> {
    [x: string]: V;
    foo: Date; // error
}

//// [subtypesOfTypeParameterWithConstraints.js]
// checking whether other types are subtypes of type parameters with constraints
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var C3 = /** @class */ (function () {
    function C3() {
    }
    return C3;
}());
var D1 = /** @class */ (function (_super) {
    __extends(D1, _super);
    function D1() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D1;
}(C3));
var D2 = /** @class */ (function (_super) {
    __extends(D2, _super);
    function D2() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D2;
}(C3));
var D3 = /** @class */ (function (_super) {
    __extends(D3, _super);
    function D3() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D3;
}(C3));
var D4 = /** @class */ (function (_super) {
    __extends(D4, _super);
    function D4() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D4;
}(C3));
// V > U > T
// test if T is subtype of T, U, V
// should all work
var D5 = /** @class */ (function (_super) {
    __extends(D5, _super);
    function D5() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D5;
}(C3));
var D6 = /** @class */ (function (_super) {
    __extends(D6, _super);
    function D6() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D6;
}(C3));
var D7 = /** @class */ (function (_super) {
    __extends(D7, _super);
    function D7() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D7;
}(C3));
// test if U is a subtype of T, U, V
// only a subtype of V and itself
var D8 = /** @class */ (function (_super) {
    __extends(D8, _super);
    function D8() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D8;
}(C3));
var D9 = /** @class */ (function (_super) {
    __extends(D9, _super);
    function D9() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D9;
}(C3));
var D10 = /** @class */ (function (_super) {
    __extends(D10, _super);
    function D10() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D10;
}(C3));
// test if V is a subtype of T, U, V
// only a subtype of itself
var D11 = /** @class */ (function (_super) {
    __extends(D11, _super);
    function D11() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D11;
}(C3));
var D12 = /** @class */ (function (_super) {
    __extends(D12, _super);
    function D12() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D12;
}(C3));
var D13 = /** @class */ (function (_super) {
    __extends(D13, _super);
    function D13() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D13;
}(C3));
// Date > V > U > T
// test if T is subtype of T, U, V, Date
// should all work
var D14 = /** @class */ (function (_super) {
    __extends(D14, _super);
    function D14() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D14;
}(C3));
var D15 = /** @class */ (function (_super) {
    __extends(D15, _super);
    function D15() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D15;
}(C3));
var D16 = /** @class */ (function (_super) {
    __extends(D16, _super);
    function D16() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D16;
}(C3));
var D17 = /** @class */ (function (_super) {
    __extends(D17, _super);
    function D17() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D17;
}(C3));
// test if U is a subtype of T, U, V, Date
// only a subtype of V, Date and itself
var D18 = /** @class */ (function (_super) {
    __extends(D18, _super);
    function D18() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D18;
}(C3));
var D19 = /** @class */ (function (_super) {
    __extends(D19, _super);
    function D19() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D19;
}(C3));
var D20 = /** @class */ (function (_super) {
    __extends(D20, _super);
    function D20() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D20;
}(C3));
var D21 = /** @class */ (function (_super) {
    __extends(D21, _super);
    function D21() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D21;
}(C3));
// test if V is a subtype of T, U, V, Date
// only a subtype of itself and Date
var D22 = /** @class */ (function (_super) {
    __extends(D22, _super);
    function D22() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D22;
}(C3));
var D23 = /** @class */ (function (_super) {
    __extends(D23, _super);
    function D23() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D23;
}(C3));
var D24 = /** @class */ (function (_super) {
    __extends(D24, _super);
    function D24() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D24;
}(C3));
var D25 = /** @class */ (function (_super) {
    __extends(D25, _super);
    function D25() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D25;
}(C3));
// test if Date is a subtype of T, U, V, Date
// only a subtype of itself
var D26 = /** @class */ (function (_super) {
    __extends(D26, _super);
    function D26() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D26;
}(C3));
var D27 = /** @class */ (function (_super) {
    __extends(D27, _super);
    function D27() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D27;
}(C3));
var D28 = /** @class */ (function (_super) {
    __extends(D28, _super);
    function D28() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D28;
}(C3));
var D29 = /** @class */ (function (_super) {
    __extends(D29, _super);
    function D29() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return D29;
}(C3));