|
| 1 | +//// [tests/cases/compiler/deferredConditionalTypes2.ts] //// |
| 2 | + |
| 3 | +=== deferredConditionalTypes2.ts === |
| 4 | +// https://github.com/microsoft/TypeScript/issues/56270 |
| 5 | + |
| 6 | +type PositiveInfinity = 1e999; |
| 7 | +>PositiveInfinity : Symbol(PositiveInfinity, Decl(deferredConditionalTypes2.ts, 0, 0)) |
| 8 | + |
| 9 | +type NegativeInfinity = -1e999; |
| 10 | +>NegativeInfinity : Symbol(NegativeInfinity, Decl(deferredConditionalTypes2.ts, 2, 30)) |
| 11 | + |
| 12 | +export type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends < |
| 13 | +>IsEqual : Symbol(IsEqual, Decl(deferredConditionalTypes2.ts, 3, 31)) |
| 14 | +>A : Symbol(A, Decl(deferredConditionalTypes2.ts, 5, 20)) |
| 15 | +>B : Symbol(B, Decl(deferredConditionalTypes2.ts, 5, 22)) |
| 16 | +>G : Symbol(G, Decl(deferredConditionalTypes2.ts, 5, 30)) |
| 17 | +>G : Symbol(G, Decl(deferredConditionalTypes2.ts, 5, 30)) |
| 18 | +>A : Symbol(A, Decl(deferredConditionalTypes2.ts, 5, 20)) |
| 19 | + |
| 20 | + G, |
| 21 | +>G : Symbol(G, Decl(deferredConditionalTypes2.ts, 5, 68)) |
| 22 | + |
| 23 | +>() => G extends B ? 1 : 2 |
| 24 | +>G : Symbol(G, Decl(deferredConditionalTypes2.ts, 5, 68)) |
| 25 | +>B : Symbol(B, Decl(deferredConditionalTypes2.ts, 5, 22)) |
| 26 | + |
| 27 | + ? true |
| 28 | + : false; |
| 29 | + |
| 30 | +export type Add<A extends number, B extends number> = [ |
| 31 | +>Add : Symbol(Add, Decl(deferredConditionalTypes2.ts, 9, 10)) |
| 32 | +>A : Symbol(A, Decl(deferredConditionalTypes2.ts, 11, 16)) |
| 33 | +>B : Symbol(B, Decl(deferredConditionalTypes2.ts, 11, 33)) |
| 34 | + |
| 35 | + IsEqual<A, PositiveInfinity>, |
| 36 | +>IsEqual : Symbol(IsEqual, Decl(deferredConditionalTypes2.ts, 3, 31)) |
| 37 | +>A : Symbol(A, Decl(deferredConditionalTypes2.ts, 11, 16)) |
| 38 | +>PositiveInfinity : Symbol(PositiveInfinity, Decl(deferredConditionalTypes2.ts, 0, 0)) |
| 39 | + |
| 40 | + IsEqual<A, NegativeInfinity>, |
| 41 | +>IsEqual : Symbol(IsEqual, Decl(deferredConditionalTypes2.ts, 3, 31)) |
| 42 | +>A : Symbol(A, Decl(deferredConditionalTypes2.ts, 11, 16)) |
| 43 | +>NegativeInfinity : Symbol(NegativeInfinity, Decl(deferredConditionalTypes2.ts, 2, 30)) |
| 44 | + |
| 45 | + IsEqual<B, PositiveInfinity>, |
| 46 | +>IsEqual : Symbol(IsEqual, Decl(deferredConditionalTypes2.ts, 3, 31)) |
| 47 | +>B : Symbol(B, Decl(deferredConditionalTypes2.ts, 11, 33)) |
| 48 | +>PositiveInfinity : Symbol(PositiveInfinity, Decl(deferredConditionalTypes2.ts, 0, 0)) |
| 49 | + |
| 50 | + IsEqual<B, NegativeInfinity>, |
| 51 | +>IsEqual : Symbol(IsEqual, Decl(deferredConditionalTypes2.ts, 3, 31)) |
| 52 | +>B : Symbol(B, Decl(deferredConditionalTypes2.ts, 11, 33)) |
| 53 | +>NegativeInfinity : Symbol(NegativeInfinity, Decl(deferredConditionalTypes2.ts, 2, 30)) |
| 54 | + |
| 55 | +] extends infer R extends [boolean, boolean, boolean, boolean] |
| 56 | +>R : Symbol(R, Decl(deferredConditionalTypes2.ts, 16, 15)) |
| 57 | + |
| 58 | + ? [true, false] extends ([R[0], R[3]]) |
| 59 | +>R : Symbol(R, Decl(deferredConditionalTypes2.ts, 16, 15)) |
| 60 | +>R : Symbol(R, Decl(deferredConditionalTypes2.ts, 16, 15)) |
| 61 | + |
| 62 | + ? PositiveInfinity |
| 63 | +>PositiveInfinity : Symbol(PositiveInfinity, Decl(deferredConditionalTypes2.ts, 0, 0)) |
| 64 | + |
| 65 | + : "failed" |
| 66 | + : never; |
| 67 | + |
| 68 | +export type AddWithoutParentheses<A extends number, B extends number> = [ |
| 69 | +>AddWithoutParentheses : Symbol(AddWithoutParentheses, Decl(deferredConditionalTypes2.ts, 20, 10)) |
| 70 | +>A : Symbol(A, Decl(deferredConditionalTypes2.ts, 22, 34)) |
| 71 | +>B : Symbol(B, Decl(deferredConditionalTypes2.ts, 22, 51)) |
| 72 | + |
| 73 | + IsEqual<A, PositiveInfinity>, |
| 74 | +>IsEqual : Symbol(IsEqual, Decl(deferredConditionalTypes2.ts, 3, 31)) |
| 75 | +>A : Symbol(A, Decl(deferredConditionalTypes2.ts, 22, 34)) |
| 76 | +>PositiveInfinity : Symbol(PositiveInfinity, Decl(deferredConditionalTypes2.ts, 0, 0)) |
| 77 | + |
| 78 | + IsEqual<A, NegativeInfinity>, |
| 79 | +>IsEqual : Symbol(IsEqual, Decl(deferredConditionalTypes2.ts, 3, 31)) |
| 80 | +>A : Symbol(A, Decl(deferredConditionalTypes2.ts, 22, 34)) |
| 81 | +>NegativeInfinity : Symbol(NegativeInfinity, Decl(deferredConditionalTypes2.ts, 2, 30)) |
| 82 | + |
| 83 | + IsEqual<B, PositiveInfinity>, |
| 84 | +>IsEqual : Symbol(IsEqual, Decl(deferredConditionalTypes2.ts, 3, 31)) |
| 85 | +>B : Symbol(B, Decl(deferredConditionalTypes2.ts, 22, 51)) |
| 86 | +>PositiveInfinity : Symbol(PositiveInfinity, Decl(deferredConditionalTypes2.ts, 0, 0)) |
| 87 | + |
| 88 | + IsEqual<B, NegativeInfinity>, |
| 89 | +>IsEqual : Symbol(IsEqual, Decl(deferredConditionalTypes2.ts, 3, 31)) |
| 90 | +>B : Symbol(B, Decl(deferredConditionalTypes2.ts, 22, 51)) |
| 91 | +>NegativeInfinity : Symbol(NegativeInfinity, Decl(deferredConditionalTypes2.ts, 2, 30)) |
| 92 | + |
| 93 | +] extends infer R extends [boolean, boolean, boolean, boolean] |
| 94 | +>R : Symbol(R, Decl(deferredConditionalTypes2.ts, 27, 15)) |
| 95 | + |
| 96 | + ? [true, false] extends [R[0], R[3]] |
| 97 | +>R : Symbol(R, Decl(deferredConditionalTypes2.ts, 27, 15)) |
| 98 | +>R : Symbol(R, Decl(deferredConditionalTypes2.ts, 27, 15)) |
| 99 | + |
| 100 | + ? PositiveInfinity |
| 101 | +>PositiveInfinity : Symbol(PositiveInfinity, Decl(deferredConditionalTypes2.ts, 0, 0)) |
| 102 | + |
| 103 | + : "failed" |
| 104 | + : never; |
| 105 | + |
| 106 | +type AddTest0 = Add<PositiveInfinity, PositiveInfinity>; |
| 107 | +>AddTest0 : Symbol(AddTest0, Decl(deferredConditionalTypes2.ts, 31, 10)) |
| 108 | +>Add : Symbol(Add, Decl(deferredConditionalTypes2.ts, 9, 10)) |
| 109 | +>PositiveInfinity : Symbol(PositiveInfinity, Decl(deferredConditionalTypes2.ts, 0, 0)) |
| 110 | +>PositiveInfinity : Symbol(PositiveInfinity, Decl(deferredConditionalTypes2.ts, 0, 0)) |
| 111 | + |
| 112 | +type AddTest1 = AddWithoutParentheses<PositiveInfinity, PositiveInfinity>; |
| 113 | +>AddTest1 : Symbol(AddTest1, Decl(deferredConditionalTypes2.ts, 33, 56)) |
| 114 | +>AddWithoutParentheses : Symbol(AddWithoutParentheses, Decl(deferredConditionalTypes2.ts, 20, 10)) |
| 115 | +>PositiveInfinity : Symbol(PositiveInfinity, Decl(deferredConditionalTypes2.ts, 0, 0)) |
| 116 | +>PositiveInfinity : Symbol(PositiveInfinity, Decl(deferredConditionalTypes2.ts, 0, 0)) |
| 117 | + |
0 commit comments