|
| 1 | +//// [tests/cases/compiler/unconstrainedTypeComparison.ts] //// |
| 2 | + |
| 3 | +=== unconstrainedTypeComparison.ts === |
| 4 | +function f1<T>(a: T, b: T): boolean { |
| 5 | +>f1 : Symbol(f1, Decl(unconstrainedTypeComparison.ts, 0, 0)) |
| 6 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 0, 12)) |
| 7 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 0, 15)) |
| 8 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 0, 12)) |
| 9 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 0, 20)) |
| 10 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 0, 12)) |
| 11 | + |
| 12 | + return a > b; |
| 13 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 0, 15)) |
| 14 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 0, 20)) |
| 15 | +} |
| 16 | + |
| 17 | +function f2<T extends {} | undefined | null>(a: T, b: T): boolean { |
| 18 | +>f2 : Symbol(f2, Decl(unconstrainedTypeComparison.ts, 2, 1)) |
| 19 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 4, 12)) |
| 20 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 4, 45)) |
| 21 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 4, 12)) |
| 22 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 4, 50)) |
| 23 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 4, 12)) |
| 24 | + |
| 25 | + return a > b; |
| 26 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 4, 45)) |
| 27 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 4, 50)) |
| 28 | +} |
| 29 | + |
| 30 | +function f3<T extends unknown>(a: T, b: T): boolean { |
| 31 | +>f3 : Symbol(f3, Decl(unconstrainedTypeComparison.ts, 6, 1)) |
| 32 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 8, 12)) |
| 33 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 8, 31)) |
| 34 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 8, 12)) |
| 35 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 8, 36)) |
| 36 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 8, 12)) |
| 37 | + |
| 38 | + return a > b; |
| 39 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 8, 31)) |
| 40 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 8, 36)) |
| 41 | +} |
| 42 | + |
| 43 | +function f4<T, U extends T>(a: U, b: U): boolean { |
| 44 | +>f4 : Symbol(f4, Decl(unconstrainedTypeComparison.ts, 10, 1)) |
| 45 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 12, 12)) |
| 46 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 12, 14)) |
| 47 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 12, 12)) |
| 48 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 12, 28)) |
| 49 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 12, 14)) |
| 50 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 12, 33)) |
| 51 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 12, 14)) |
| 52 | + |
| 53 | + return a > b; |
| 54 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 12, 28)) |
| 55 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 12, 33)) |
| 56 | +} |
| 57 | + |
| 58 | +function f5<T extends {} | undefined | null, U extends T>(a: U, b: U): boolean { |
| 59 | +>f5 : Symbol(f5, Decl(unconstrainedTypeComparison.ts, 14, 1)) |
| 60 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 16, 12)) |
| 61 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 16, 44)) |
| 62 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 16, 12)) |
| 63 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 16, 58)) |
| 64 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 16, 44)) |
| 65 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 16, 63)) |
| 66 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 16, 44)) |
| 67 | + |
| 68 | + return a > b; |
| 69 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 16, 58)) |
| 70 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 16, 63)) |
| 71 | +} |
| 72 | + |
| 73 | +function f6<T extends unknown, U extends T>(a: U, b: U): boolean { |
| 74 | +>f6 : Symbol(f6, Decl(unconstrainedTypeComparison.ts, 18, 1)) |
| 75 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 20, 12)) |
| 76 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 20, 30)) |
| 77 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 20, 12)) |
| 78 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 20, 44)) |
| 79 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 20, 30)) |
| 80 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 20, 49)) |
| 81 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 20, 30)) |
| 82 | + |
| 83 | + return a > b; |
| 84 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 20, 44)) |
| 85 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 20, 49)) |
| 86 | +} |
| 87 | + |
| 88 | +function f7<T extends {} | undefined, U extends T>(a: U, b: U): boolean { |
| 89 | +>f7 : Symbol(f7, Decl(unconstrainedTypeComparison.ts, 22, 1)) |
| 90 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 24, 12)) |
| 91 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 24, 37)) |
| 92 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 24, 12)) |
| 93 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 24, 51)) |
| 94 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 24, 37)) |
| 95 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 24, 56)) |
| 96 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 24, 37)) |
| 97 | + |
| 98 | + return a > b; |
| 99 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 24, 51)) |
| 100 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 24, 56)) |
| 101 | +} |
| 102 | + |
| 103 | +function f8<T extends {} | null, U extends T>(a: U, b: U): boolean { |
| 104 | +>f8 : Symbol(f8, Decl(unconstrainedTypeComparison.ts, 26, 1)) |
| 105 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 28, 12)) |
| 106 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 28, 32)) |
| 107 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 28, 12)) |
| 108 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 28, 46)) |
| 109 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 28, 32)) |
| 110 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 28, 51)) |
| 111 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 28, 32)) |
| 112 | + |
| 113 | + return a > b; |
| 114 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 28, 46)) |
| 115 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 28, 51)) |
| 116 | +} |
| 117 | + |
| 118 | +function f9<T extends undefined | null, U extends T>(a: U, b: U): boolean { |
| 119 | +>f9 : Symbol(f9, Decl(unconstrainedTypeComparison.ts, 30, 1)) |
| 120 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 32, 12)) |
| 121 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 32, 39)) |
| 122 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 32, 12)) |
| 123 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 32, 53)) |
| 124 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 32, 39)) |
| 125 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 32, 58)) |
| 126 | +>U : Symbol(U, Decl(unconstrainedTypeComparison.ts, 32, 39)) |
| 127 | + |
| 128 | + return a > b; |
| 129 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 32, 53)) |
| 130 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 32, 58)) |
| 131 | +} |
| 132 | + |
| 133 | + |
| 134 | +function compare<T>(a: T, b: T): boolean { |
| 135 | +>compare : Symbol(compare, Decl(unconstrainedTypeComparison.ts, 34, 1)) |
| 136 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 37, 17)) |
| 137 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 37, 20)) |
| 138 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 37, 17)) |
| 139 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 37, 25)) |
| 140 | +>T : Symbol(T, Decl(unconstrainedTypeComparison.ts, 37, 17)) |
| 141 | + |
| 142 | + if (a === undefined) { |
| 143 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 37, 20)) |
| 144 | +>undefined : Symbol(undefined) |
| 145 | + |
| 146 | + return false; |
| 147 | + } |
| 148 | + if (b === null) { |
| 149 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 37, 25)) |
| 150 | + |
| 151 | + return false; |
| 152 | + } |
| 153 | + return a > b; |
| 154 | +>a : Symbol(a, Decl(unconstrainedTypeComparison.ts, 37, 20)) |
| 155 | +>b : Symbol(b, Decl(unconstrainedTypeComparison.ts, 37, 25)) |
| 156 | +} |
0 commit comments