|
| 1 | +=== tests/cases/compiler/overloadsWithComputedNames.ts === |
| 2 | +// https://github.com/microsoft/TypeScript/issues/52329 |
| 3 | +class Person { |
| 4 | +>Person : Symbol(Person, Decl(overloadsWithComputedNames.ts, 0, 0)) |
| 5 | + |
| 6 | + ["B"](a: number): string; |
| 7 | +>["B"] : Symbol(Person["B"], Decl(overloadsWithComputedNames.ts, 1, 14)) |
| 8 | +>"B" : Symbol(Person["B"], Decl(overloadsWithComputedNames.ts, 1, 14)) |
| 9 | +>a : Symbol(a, Decl(overloadsWithComputedNames.ts, 2, 10)) |
| 10 | + |
| 11 | + ["A"](a: string|number): number | string { |
| 12 | +>["A"] : Symbol(Person["A"], Decl(overloadsWithComputedNames.ts, 2, 29)) |
| 13 | +>"A" : Symbol(Person["A"], Decl(overloadsWithComputedNames.ts, 2, 29)) |
| 14 | +>a : Symbol(a, Decl(overloadsWithComputedNames.ts, 3, 10)) |
| 15 | + |
| 16 | + return 0; |
| 17 | + } |
| 18 | +} |
| 19 | +let p = new Person(); |
| 20 | +>p : Symbol(p, Decl(overloadsWithComputedNames.ts, 7, 3)) |
| 21 | +>Person : Symbol(Person, Decl(overloadsWithComputedNames.ts, 0, 0)) |
| 22 | + |
| 23 | +p.A(0) |
| 24 | +>p.A : Symbol(Person["A"], Decl(overloadsWithComputedNames.ts, 2, 29)) |
| 25 | +>p : Symbol(p, Decl(overloadsWithComputedNames.ts, 7, 3)) |
| 26 | +>A : Symbol(Person["A"], Decl(overloadsWithComputedNames.ts, 2, 29)) |
| 27 | + |
| 28 | +p.B(0) |
| 29 | +>p.B : Symbol(Person["B"], Decl(overloadsWithComputedNames.ts, 1, 14)) |
| 30 | +>p : Symbol(p, Decl(overloadsWithComputedNames.ts, 7, 3)) |
| 31 | +>B : Symbol(Person["B"], Decl(overloadsWithComputedNames.ts, 1, 14)) |
| 32 | + |
| 33 | +// https://github.com/microsoft/TypeScript/issues/17345 |
| 34 | +class C { |
| 35 | +>C : Symbol(C, Decl(overloadsWithComputedNames.ts, 9, 6)) |
| 36 | + |
| 37 | + ["foo"](): void |
| 38 | +>["foo"] : Symbol(C["foo"], Decl(overloadsWithComputedNames.ts, 12, 9), Decl(overloadsWithComputedNames.ts, 14, 20)) |
| 39 | +>"foo" : Symbol(C["foo"], Decl(overloadsWithComputedNames.ts, 12, 9), Decl(overloadsWithComputedNames.ts, 14, 20)) |
| 40 | + |
| 41 | + ["bar"](): void; |
| 42 | +>["bar"] : Symbol(C["bar"], Decl(overloadsWithComputedNames.ts, 13, 19)) |
| 43 | +>"bar" : Symbol(C["bar"], Decl(overloadsWithComputedNames.ts, 13, 19)) |
| 44 | + |
| 45 | + ["foo"]() { |
| 46 | +>["foo"] : Symbol(C["foo"], Decl(overloadsWithComputedNames.ts, 12, 9), Decl(overloadsWithComputedNames.ts, 14, 20)) |
| 47 | +>"foo" : Symbol(C["foo"], Decl(overloadsWithComputedNames.ts, 12, 9), Decl(overloadsWithComputedNames.ts, 14, 20)) |
| 48 | + |
| 49 | + return 0; |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +declare const uniqueSym: unique symbol; |
| 54 | +>uniqueSym : Symbol(uniqueSym, Decl(overloadsWithComputedNames.ts, 20, 13)) |
| 55 | + |
| 56 | +declare const uniqueSym2: unique symbol; |
| 57 | +>uniqueSym2 : Symbol(uniqueSym2, Decl(overloadsWithComputedNames.ts, 21, 13)) |
| 58 | + |
| 59 | +declare const sym: symbol; |
| 60 | +>sym : Symbol(sym, Decl(overloadsWithComputedNames.ts, 22, 13)) |
| 61 | + |
| 62 | +declare const strUnion: 'foo' | 'bar'; |
| 63 | +>strUnion : Symbol(strUnion, Decl(overloadsWithComputedNames.ts, 24, 13)) |
| 64 | + |
| 65 | +class C1 { |
| 66 | +>C1 : Symbol(C1, Decl(overloadsWithComputedNames.ts, 24, 38)) |
| 67 | + |
| 68 | + [sym](): void; // should error |
| 69 | +>[sym] : Symbol(C1[sym], Decl(overloadsWithComputedNames.ts, 26, 10)) |
| 70 | +>sym : Symbol(sym, Decl(overloadsWithComputedNames.ts, 22, 13)) |
| 71 | + |
| 72 | + [uniqueSym2](): void; // should error |
| 73 | +>[uniqueSym2] : Symbol(C1[uniqueSym2], Decl(overloadsWithComputedNames.ts, 27, 18)) |
| 74 | +>uniqueSym2 : Symbol(uniqueSym2, Decl(overloadsWithComputedNames.ts, 21, 13)) |
| 75 | + |
| 76 | + [uniqueSym](): void; |
| 77 | +>[uniqueSym] : Symbol(C1[uniqueSym], Decl(overloadsWithComputedNames.ts, 28, 25), Decl(overloadsWithComputedNames.ts, 29, 24)) |
| 78 | +>uniqueSym : Symbol(uniqueSym, Decl(overloadsWithComputedNames.ts, 20, 13)) |
| 79 | + |
| 80 | + [uniqueSym]() { } |
| 81 | +>[uniqueSym] : Symbol(C1[uniqueSym], Decl(overloadsWithComputedNames.ts, 28, 25), Decl(overloadsWithComputedNames.ts, 29, 24)) |
| 82 | +>uniqueSym : Symbol(uniqueSym, Decl(overloadsWithComputedNames.ts, 20, 13)) |
| 83 | +} |
| 84 | + |
| 85 | +interface I1 { |
| 86 | +>I1 : Symbol(I1, Decl(overloadsWithComputedNames.ts, 31, 1)) |
| 87 | + |
| 88 | + [sym](): void; // should error |
| 89 | +>[sym] : Symbol(I1[sym], Decl(overloadsWithComputedNames.ts, 33, 14)) |
| 90 | +>sym : Symbol(sym, Decl(overloadsWithComputedNames.ts, 22, 13)) |
| 91 | + |
| 92 | + [uniqueSym2](): void; |
| 93 | +>[uniqueSym2] : Symbol(I1[uniqueSym2], Decl(overloadsWithComputedNames.ts, 34, 18)) |
| 94 | +>uniqueSym2 : Symbol(uniqueSym2, Decl(overloadsWithComputedNames.ts, 21, 13)) |
| 95 | + |
| 96 | + [uniqueSym](): void; |
| 97 | +>[uniqueSym] : Symbol(I1[uniqueSym], Decl(overloadsWithComputedNames.ts, 35, 25), Decl(overloadsWithComputedNames.ts, 36, 24)) |
| 98 | +>uniqueSym : Symbol(uniqueSym, Decl(overloadsWithComputedNames.ts, 20, 13)) |
| 99 | + |
| 100 | + [uniqueSym](): void; |
| 101 | +>[uniqueSym] : Symbol(I1[uniqueSym], Decl(overloadsWithComputedNames.ts, 35, 25), Decl(overloadsWithComputedNames.ts, 36, 24)) |
| 102 | +>uniqueSym : Symbol(uniqueSym, Decl(overloadsWithComputedNames.ts, 20, 13)) |
| 103 | +} |
| 104 | + |
| 105 | +class C2 { |
| 106 | +>C2 : Symbol(C2, Decl(overloadsWithComputedNames.ts, 38, 1)) |
| 107 | + |
| 108 | + [strUnion](): void; // should error |
| 109 | +>[strUnion] : Symbol(C2[strUnion], Decl(overloadsWithComputedNames.ts, 40, 10)) |
| 110 | +>strUnion : Symbol(strUnion, Decl(overloadsWithComputedNames.ts, 24, 13)) |
| 111 | + |
| 112 | + [strUnion]() { } |
| 113 | +>[strUnion] : Symbol(C2[strUnion], Decl(overloadsWithComputedNames.ts, 41, 23)) |
| 114 | +>strUnion : Symbol(strUnion, Decl(overloadsWithComputedNames.ts, 24, 13)) |
| 115 | +} |
| 116 | + |
| 117 | +class I2 { |
| 118 | +>I2 : Symbol(I2, Decl(overloadsWithComputedNames.ts, 43, 1)) |
| 119 | + |
| 120 | + [strUnion](): void; // should error |
| 121 | +>[strUnion] : Symbol(I2[strUnion], Decl(overloadsWithComputedNames.ts, 45, 10)) |
| 122 | +>strUnion : Symbol(strUnion, Decl(overloadsWithComputedNames.ts, 24, 13)) |
| 123 | + |
| 124 | + [strUnion]() { } |
| 125 | +>[strUnion] : Symbol(I2[strUnion], Decl(overloadsWithComputedNames.ts, 46, 23)) |
| 126 | +>strUnion : Symbol(strUnion, Decl(overloadsWithComputedNames.ts, 24, 13)) |
| 127 | +} |
| 128 | + |
| 129 | +class C3 { |
| 130 | +>C3 : Symbol(C3, Decl(overloadsWithComputedNames.ts, 48, 1)) |
| 131 | + |
| 132 | + [1](): void; // should error |
| 133 | +>[1] : Symbol(C3[1], Decl(overloadsWithComputedNames.ts, 50, 10)) |
| 134 | +>1 : Symbol(C3[1], Decl(overloadsWithComputedNames.ts, 50, 10)) |
| 135 | + |
| 136 | + [2](): void; |
| 137 | +>[2] : Symbol(C3[2], Decl(overloadsWithComputedNames.ts, 51, 16), Decl(overloadsWithComputedNames.ts, 52, 16)) |
| 138 | +>2 : Symbol(C3[2], Decl(overloadsWithComputedNames.ts, 51, 16), Decl(overloadsWithComputedNames.ts, 52, 16)) |
| 139 | + |
| 140 | + [2]() { } |
| 141 | +>[2] : Symbol(C3[2], Decl(overloadsWithComputedNames.ts, 51, 16), Decl(overloadsWithComputedNames.ts, 52, 16)) |
| 142 | +>2 : Symbol(C3[2], Decl(overloadsWithComputedNames.ts, 51, 16), Decl(overloadsWithComputedNames.ts, 52, 16)) |
| 143 | +} |
| 144 | + |
| 145 | +interface I3 { |
| 146 | +>I3 : Symbol(I3, Decl(overloadsWithComputedNames.ts, 54, 1)) |
| 147 | + |
| 148 | + [1](): void; |
| 149 | +>[1] : Symbol(I3[1], Decl(overloadsWithComputedNames.ts, 56, 14)) |
| 150 | +>1 : Symbol(I3[1], Decl(overloadsWithComputedNames.ts, 56, 14)) |
| 151 | + |
| 152 | + [2](): void; |
| 153 | +>[2] : Symbol(I3[2], Decl(overloadsWithComputedNames.ts, 57, 16), Decl(overloadsWithComputedNames.ts, 58, 16)) |
| 154 | +>2 : Symbol(I3[2], Decl(overloadsWithComputedNames.ts, 57, 16), Decl(overloadsWithComputedNames.ts, 58, 16)) |
| 155 | + |
| 156 | + [2](): void; |
| 157 | +>[2] : Symbol(I3[2], Decl(overloadsWithComputedNames.ts, 57, 16), Decl(overloadsWithComputedNames.ts, 58, 16)) |
| 158 | +>2 : Symbol(I3[2], Decl(overloadsWithComputedNames.ts, 57, 16), Decl(overloadsWithComputedNames.ts, 58, 16)) |
| 159 | +} |
0 commit comments