@@ -8,9 +8,28 @@ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(42,5): error TS2322:
8
8
tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(43,5): error TS2322: Type 'Uppercase<T>' is not assignable to type 'Uppercase<U>'.
9
9
Type 'T' is not assignable to type 'U'.
10
10
'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string'.
11
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(61,20): error TS2344: Type 'string' does not satisfy the constraint 'number'.
12
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(76,17): error TS2344: Type 'string' does not satisfy the constraint 'number'.
13
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(77,20): error TS2344: Type 'string' does not satisfy the constraint 'number'.
14
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(78,18): error TS2344: Type 'string' does not satisfy the constraint 'number'.
15
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(93,22): error TS2344: Type 'string' does not satisfy the constraint 'number'.
16
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(94,25): error TS2344: Type 'string' does not satisfy the constraint 'number'.
17
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(95,23): error TS2344: Type 'string' does not satisfy the constraint 'number'.
18
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(110,22): error TS2344: Type 'string' does not satisfy the constraint 'number'.
19
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(111,25): error TS2344: Type 'string' does not satisfy the constraint 'number'.
20
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(112,23): error TS2344: Type 'string' does not satisfy the constraint 'number'.
21
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(127,20): error TS2344: Type 'string' does not satisfy the constraint 'number'.
22
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(128,23): error TS2344: Type 'string' does not satisfy the constraint 'number'.
23
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(129,21): error TS2344: Type 'string' does not satisfy the constraint 'number'.
24
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(146,5): error TS2322: Type 'number' is not assignable to type 'Add<T, U>'.
25
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(147,5): error TS2322: Type 'Multiply<T, U>' is not assignable to type 'Add<T, U>'.
26
+ Type 'number' is not assignable to type 'Add<T, U>'.
27
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(148,5): error TS2322: Type 'number' is not assignable to type 'Multiply<T, U>'.
28
+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(149,5): error TS2322: Type 'Add<T, U>' is not assignable to type 'Multiply<T, U>'.
29
+ Type 'number' is not assignable to type 'Multiply<T, U>'.
11
30
12
31
13
- ==== tests/cases/conformance/types/typeAliases/intrinsicTypes.ts (8 errors) ====
32
+ ==== tests/cases/conformance/types/typeAliases/intrinsicTypes.ts (25 errors) ====
14
33
type TU1 = Uppercase<'hello'>; // "HELLO"
15
34
type TU2 = Uppercase<'foo' | 'bar'>; // "FOO" | "BAR"
16
35
type TU3 = Uppercase<string>; // string
@@ -83,4 +102,146 @@ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(43,5): error TS2322:
83
102
function foo4<U extends string>(x: Uppercase<U>) {
84
103
return foo3(x);
85
104
}
105
+
106
+ type TI1 = Integer<3.5>; // 3
107
+ type TI2 = Integer<2.5 | 3.4>; // 2 | 3
108
+ type TI3 = Integer<number>; // number
109
+ type TI4 = Integer<any>; // any
110
+ type TI5 = Integer<never>; // never
111
+ type TI6 = Integer<'42'>; // Error
112
+ ~~~~
113
+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
114
+
115
+ type TA1 = Add<4, 2>; // 6
116
+ type TA2L = Add<4 | 5, 2>; // 6 | 7
117
+ type TA2R = Add<4, 2 | 3>; // 6 | 7
118
+ type TA2LR = Add<4 | 5, 2 | 3>; // 6 | 7 | 8
119
+ type TA3L = Add<number, 2>; // number
120
+ type TA3R = Add<4, number>; // number
121
+ type TA3LR = Add<number, number>; // number
122
+ type TA4L = Add<any, 2>; // any
123
+ type TA4R = Add<4, any>; // any
124
+ type TA4LR = Add<any, any>; // any
125
+ type TA5L = Add<never, 2>; // never
126
+ type TA5R = Add<4, never>; // never
127
+ type TA5LR = Add<never, never>; // never
128
+ type TA6L = Add<'4', 2>; // Error
129
+ ~~~
130
+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
131
+ type TA6R = Add<4, '2'>; // Error
132
+ ~~~
133
+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
134
+ type TA6LR = Add<'4', '2'>; // Error
135
+ ~~~
136
+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
137
+
138
+ type TS1 = Subtract<4, 2>; // 2
139
+ type TS2L = Subtract<4 | 5, 2>; // 2 | 3
140
+ type TS2R = Subtract<4, 2 | 3>; // 2 | 1
141
+ type TS2LR = Subtract<4 | 5, 2 | 3>; // 2 | 1 | 3
142
+ type TS3L = Subtract<number, 2>; // number
143
+ type TS3R = Subtract<4, number>; // number
144
+ type TS3LR = Subtract<number, number>; // number
145
+ type TS4L = Subtract<any, 2>; // any
146
+ type TS4R = Subtract<4, any>; // any
147
+ type TS4LR = Subtract<any, any>; // any
148
+ type TS5L = Subtract<never, 2>; // never
149
+ type TS5R = Subtract<4, never>; // never
150
+ type TS5LR = Subtract<never, never>; // never
151
+ type TS6L = Subtract<'4', 2>; // Error
152
+ ~~~
153
+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
154
+ type TS6R = Subtract<4, '2'>; // Error
155
+ ~~~
156
+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
157
+ type TS6LR = Subtract<'4', '2'>; // Error
158
+ ~~~
159
+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
160
+
161
+ type TM1 = Multiply<4, 2>; // 8
162
+ type TM2L = Multiply<4 | 5, 2>; // 8 | 10
163
+ type TM2R = Multiply<4, 2 | 3>; // 8 | 12
164
+ type TM2LR = Multiply<4 | 5, 2 | 3>; // 8 | 12 | 10 | 15
165
+ type TM3L = Multiply<number, 2>; // number
166
+ type TM3R = Multiply<4, number>; // number
167
+ type TM3LR = Multiply<number, number>; // number
168
+ type TM4L = Multiply<any, 2>; // any
169
+ type TM4R = Multiply<4, any>; // any
170
+ type TM4LR = Multiply<any, any>; // any
171
+ type TM5L = Multiply<never, 2>; // never
172
+ type TM5R = Multiply<4, never>; // never
173
+ type TM5LR = Multiply<never, never>; // never
174
+ type TM6L = Multiply<'4', 2>; // Error
175
+ ~~~
176
+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
177
+ type TM6R = Multiply<4, '2'>; // Error
178
+ ~~~
179
+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
180
+ type TM6LR = Multiply<'4', '2'>; // Error
181
+ ~~~
182
+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
183
+
184
+ type TD1 = Divide<4, 2>; // 2
185
+ type TD2L = Divide<4 | 5, 2>; // 2 | 2.5
186
+ type TD2R = Divide<4, 2 | 4>; // 2 | 1
187
+ type TD2LR = Divide<4 | 5, 2 | 4>; // 2 | 1 | 2.5 | 1.25
188
+ type TD3L = Divide<number, 2>; // number
189
+ type TD3R = Divide<4, number>; // number
190
+ type TD3LR = Divide<number, number>; // number
191
+ type TD4L = Divide<any, 2>; // any
192
+ type TD4R = Divide<4, any>; // any
193
+ type TD4LR = Divide<any, any>; // any
194
+ type TD5L = Divide<never, 2>; // never
195
+ type TD5R = Divide<4, never>; // never
196
+ type TD5LR = Divide<never, never>; // never
197
+ type TD6L = Divide<'4', 2>; // Error
198
+ ~~~
199
+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
200
+ type TD6R = Divide<4, '2'>; // Error
201
+ ~~~
202
+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
203
+ type TD6LR = Divide<'4', '2'>; // Error
204
+ ~~~
205
+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
206
+
207
+ type TIX1<S extends number> = Integer<S>;
208
+ type TIX2 = TIX1<4.2>; // 4
209
+ type TAX1<M extends number, N extends number> = Add<M, N>;
210
+ type TAX2 = TAX1<4, 2>; // 6
211
+ type TSX1<M extends number, N extends number> = Subtract<M, N>;
212
+ type TSX2 = TSX1<4, 2>; // 6
213
+ type TMX1<M extends number, N extends number> = Multiply<M, N>;
214
+ type TMX2 = TMX1<4, 2>; // 8
215
+ type TDX1<M extends number, N extends number> = Divide<M, N>;
216
+ type TDX2 = TDX1<4, 2>; // 2
217
+ type TAMX = Add<2, Multiply<5, 8>> // 42
218
+
219
+ function foo5<T extends number, U extends T>(s: number, x: Add<T, U>, y: Multiply<T, U>) {
220
+ s = x;
221
+ s = y;
222
+ x = s; // Error
223
+ ~
224
+ !!! error TS2322: Type 'number' is not assignable to type 'Add<T, U>'.
225
+ x = y; // Error
226
+ ~
227
+ !!! error TS2322: Type 'Multiply<T, U>' is not assignable to type 'Add<T, U>'.
228
+ !!! error TS2322: Type 'number' is not assignable to type 'Add<T, U>'.
229
+ y = s; // Error
230
+ ~
231
+ !!! error TS2322: Type 'number' is not assignable to type 'Multiply<T, U>'.
232
+ y = x; // Error
233
+ ~
234
+ !!! error TS2322: Type 'Add<T, U>' is not assignable to type 'Multiply<T, U>'.
235
+ !!! error TS2322: Type 'number' is not assignable to type 'Multiply<T, U>'.
236
+ }
237
+
238
+ function foo6<T extends 0 | 1>(x: Add<T, 3>) {
239
+ let s: 3 | 4 = x;
240
+ }
241
+
242
+ declare function foo7<T extends number>(x: Integer<T>): T;
243
+
244
+ function foo8<U extends number>(x: Integer<U>) {
245
+ return foo7(x);
246
+ }
86
247
0 commit comments