@@ -8,9 +8,28 @@ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(42,5): error TS2322:
88tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(43,5): error TS2322: Type 'Uppercase<T>' is not assignable to type 'Uppercase<U>'.
99 Type 'T' is not assignable to type 'U'.
1010 '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(112,23): error TS2344: Type 'string' does not satisfy the constraint 'number'.
19+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(113,26): error TS2344: Type 'string' does not satisfy the constraint 'number'.
20+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(114,24): error TS2344: Type 'string' does not satisfy the constraint 'number'.
21+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(131,26): error TS2344: Type 'string' does not satisfy the constraint 'number'.
22+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(132,29): error TS2344: Type 'string' does not satisfy the constraint 'number'.
23+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(133,27): error TS2344: Type 'string' does not satisfy the constraint 'number'.
24+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(149,5): error TS2322: Type 'number' is not assignable to type 'Add<T, U>'.
25+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(150,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(151,5): error TS2322: Type 'number' is not assignable to type 'Multiply<T, U>'.
28+ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(152,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>'.
1130
1231
13- ==== tests/cases/conformance/types/typeAliases/intrinsicTypes.ts (8 errors) ====
32+ ==== tests/cases/conformance/types/typeAliases/intrinsicTypes.ts (25 errors) ====
1433 type TU1 = Uppercase<'hello'>; // "HELLO"
1534 type TU2 = Uppercase<'foo' | 'bar'>; // "FOO" | "BAR"
1635 type TU3 = Uppercase<string>; // string
@@ -83,4 +102,149 @@ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(43,5): error TS2322:
83102 function foo4<U extends string>(x: Uppercase<U>) {
84103 return foo3(x);
85104 }
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 TM1 = Multiply<4, 2>; // 8
139+ type TM2L = Multiply<4 | 5, 2>; // 8 | 10
140+ type TM2R = Multiply<4, 2 | 3>; // 8 | 12
141+ type TM2LR = Multiply<4 | 5, 2 | 3>; // 8 | 12 | 10 | 15
142+ type TM3L = Multiply<number, 2>; // number
143+ type TM3R = Multiply<4, number>; // number
144+ type TM3LR = Multiply<number, number>; // number
145+ type TM4L = Multiply<any, 2>; // any
146+ type TM4R = Multiply<4, any>; // any
147+ type TM4LR = Multiply<any, any>; // any
148+ type TM5L = Multiply<never, 2>; // never
149+ type TM5R = Multiply<4, never>; // never
150+ type TM5LR = Multiply<never, never>; // never
151+ type TM6L = Multiply<'4', 2>; // Error
152+ ~~~
153+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
154+ type TM6R = Multiply<4, '2'>; // Error
155+ ~~~
156+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
157+ type TM6LR = Multiply<'4', '2'>; // Error
158+ ~~~
159+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
160+
161+ type TLT1GT = LessThan<4, 2>; // never
162+ type TLT1LT = LessThan<2, 4>; // 2
163+ type TLT1EQ = LessThan<4, 4>; // never
164+ type TLT2L = LessThan<1 | 2 | 3, 2>; // 1
165+ type TLT2R = LessThan<2, 1 | 2 | 3>; // 2
166+ type TLT2LR = LessThan<1 | 2, 1 | 2 | 3>; // 1 | 2
167+ type TLT3L = LessThan<number, 2>; // number
168+ type TLT3R = LessThan<4, number>; // number
169+ type TLT3LR = LessThan<number, number>; // number
170+ type TLT4L = LessThan<any, 2>; // any
171+ type TLT4R = LessThan<4, any>; // any
172+ type TLT4LR = LessThan<any, any>; // any
173+ type TLT5L = LessThan<never, 2>; // never
174+ type TLT5R = LessThan<4, never>; // never
175+ type TLT5LR = LessThan<never, never>; // never
176+ type TLT6L = LessThan<'4', 2>; // Error
177+ ~~~
178+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
179+ type TLT6R = LessThan<4, '2'>; // Error
180+ ~~~
181+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
182+ type TLT6LR = LessThan<'4', '2'>; // Error
183+ ~~~
184+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
185+
186+ type TGT1GT = GreaterThan<4, 2>; // 4
187+ type TGT1LT = GreaterThan<2, 4>; // never
188+ type TGT1EQ = GreaterThan<4, 4>; // never
189+ type TGT2L = GreaterThan<1 | 2 | 3, 2>; // 3
190+ type TGT2R = GreaterThan<2, 1 | 2 | 3>; // 2
191+ type TGT2LR = GreaterThan<1 | 2, 1 | 2 | 3>; // 2
192+ type TGT3L = GreaterThan<number, 2>; // number
193+ type TGT3R = GreaterThan<4, number>; // number
194+ type TGT3LR = GreaterThan<number, number>; // number
195+ type TGT4L = GreaterThan<any, 2>; // any
196+ type TGT4R = GreaterThan<4, any>; // any
197+ type TGT4LR = GreaterThan<any, any>; // any
198+ type TGT5L = GreaterThan<never, 2>; // never
199+ type TGT5R = GreaterThan<4, never>; // never
200+ type TGT5LR = GreaterThan<never, never>; // never
201+ type TGT6L = GreaterThan<'4', 2>; // Error
202+ ~~~
203+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
204+ type TGT6R = GreaterThan<4, '2'>; // Error
205+ ~~~
206+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
207+ type TGT6LR = GreaterThan<'4', '2'>; // Error
208+ ~~~
209+ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'.
210+
211+ type TIX1<S extends number> = Integer<S>;
212+ type TIX2 = TIX1<4.2>; // 4
213+ type TAX1<M extends number, N extends number> = Add<M, N>;
214+ type TAX2 = TAX1<4, 2>; // 6
215+ type TMX1<M extends number, N extends number> = Multiply<M, N>;
216+ type TMX2 = TMX1<4, 2>; // 8
217+ type TLTX1<M extends number, N extends number> = LessThan<M, N>;
218+ type TLTX2 = TLTX1<2, 4>; // 2
219+ type TLTX3 = TLTX1<5, 4>; // never
220+ type TAMX = Add<2, Multiply<5, 8>> // 42
221+
222+ function foo5<T extends number, U extends T>(s: number, x: Add<T, U>, y: Multiply<T, U>) {
223+ s = x;
224+ s = y;
225+ x = s; // Error
226+ ~
227+ !!! error TS2322: Type 'number' is not assignable to type 'Add<T, U>'.
228+ x = y; // Error
229+ ~
230+ !!! error TS2322: Type 'Multiply<T, U>' is not assignable to type 'Add<T, U>'.
231+ !!! error TS2322: Type 'number' is not assignable to type 'Add<T, U>'.
232+ y = s; // Error
233+ ~
234+ !!! error TS2322: Type 'number' is not assignable to type 'Multiply<T, U>'.
235+ y = x; // Error
236+ ~
237+ !!! error TS2322: Type 'Add<T, U>' is not assignable to type 'Multiply<T, U>'.
238+ !!! error TS2322: Type 'number' is not assignable to type 'Multiply<T, U>'.
239+ }
240+
241+ function foo6<T extends 0 | 1>(x: Add<T, 3>) {
242+ let s: 3 | 4 = x;
243+ }
244+
245+ declare function foo7<T extends number>(x: Integer<T>): T;
246+
247+ function foo8<U extends number>(x: Integer<U>) {
248+ return foo7(x);
249+ }
86250
0 commit comments