File: subtypesOfTypeParameterWithConstraints4.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (216 lines) | stat: -rw-r--r-- 3,457 bytes parent folder | download | duplicates (5)
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
=== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts ===
// checking whether other types are subtypes of type parameters with constraints

class Foo { foo: number; }
>Foo : Foo
>foo : number

function f<T extends Foo, U extends Foo, V>(t: T, u: U, v: V) {
>f : <T extends Foo, U extends Foo, V>(t: T, u: U, v: V) => void
>t : T
>u : U
>v : V

    // ok
    var r = true ? t : u;
>r : T | U
>true ? t : u : T | U
>true : true
>t : T
>u : U

    var r = true ? u : t;
>r : T | U
>true ? u : t : T | U
>true : true
>u : U
>t : T

    // ok
    var r2 = true ? t : v;
>r2 : T | V
>true ? t : v : T | V
>true : true
>t : T
>v : V

    var r2 = true ? v : t;
>r2 : T | V
>true ? v : t : T | V
>true : true
>v : V
>t : T

    // ok
    var r3 = true ? v : u;
>r3 : U | V
>true ? v : u : U | V
>true : true
>v : V
>u : U

    var r3 = true ? u : v;
>r3 : U | V
>true ? u : v : U | V
>true : true
>u : U
>v : V

    // ok
    var r4 = true ? t : new Foo();
>r4 : Foo
>true ? t : new Foo() : Foo
>true : true
>t : T
>new Foo() : Foo
>Foo : typeof Foo

    var r4 = true ? new Foo() : t;
>r4 : Foo
>true ? new Foo() : t : Foo
>true : true
>new Foo() : Foo
>Foo : typeof Foo
>t : T

    // ok
    var r5 = true ? u : new Foo();
>r5 : Foo
>true ? u : new Foo() : Foo
>true : true
>u : U
>new Foo() : Foo
>Foo : typeof Foo

    var r5 = true ? new Foo() : u;
>r5 : Foo
>true ? new Foo() : u : Foo
>true : true
>new Foo() : Foo
>Foo : typeof Foo
>u : U

    // ok
    var r6 = true ? v : new Foo();
>r6 : Foo | V
>true ? v : new Foo() : Foo | V
>true : true
>v : V
>new Foo() : Foo
>Foo : typeof Foo

    var r6 = true ? new Foo() : v;
>r6 : Foo | V
>true ? new Foo() : v : Foo | V
>true : true
>new Foo() : Foo
>Foo : typeof Foo
>v : V

}

class B1<T> {
>B1 : B1<T>

    foo: T;
>foo : T
}

class D1<T extends Foo, U extends Foo, V> extends B1<Foo> {
>D1 : D1<T, U, V>
>B1 : B1<Foo>

    [x: string]: Foo;
>x : string

    foo: T; // ok
>foo : T
}

class D2<T extends Foo, U extends Foo, V> extends B1<Foo> {
>D2 : D2<T, U, V>
>B1 : B1<Foo>

    [x: string]: Foo;
>x : string

    foo: U; // ok
>foo : U
}

class D3<T extends Foo, U extends Foo, V> extends B1<Foo> {
>D3 : D3<T, U, V>
>B1 : B1<Foo>

    [x: string]: Foo;
>x : string

    foo: V; // error
>foo : V
}

class D4<T extends Foo, U extends Foo, V> extends B1<T> {
>D4 : D4<T, U, V>
>B1 : B1<T>

    [x: string]: T;
>x : string

    foo: T; // ok
>foo : T
}

class D5<T extends Foo, U extends Foo, V> extends B1<T> {
>D5 : D5<T, U, V>
>B1 : B1<T>

    [x: string]: T;
>x : string

    foo: U; // error
>foo : U
}

class D6<T extends Foo, U extends Foo, V> extends B1<T> {
>D6 : D6<T, U, V>
>B1 : B1<T>

    [x: string]: T;
>x : string

    foo: V; // error
>foo : V
}

class D7<T extends Foo, U extends Foo, V> extends B1<U> {
>D7 : D7<T, U, V>
>B1 : B1<U>

    [x: string]: U;
>x : string

    foo: T; // error
>foo : T
}

class D8<T extends Foo, U extends Foo, V> extends B1<U> {
>D8 : D8<T, U, V>
>B1 : B1<U>

    [x: string]: U;
>x : string

    foo: U; // ok
>foo : U
}

class D9<T extends Foo, U extends Foo, V> extends B1<U> {
>D9 : D9<T, U, V>
>B1 : B1<U>

    [x: string]: U;
>x : string

    foo: V; // error
>foo : V
}