Skip to content

Commit 64fd857

Browse files
committed
fix symbol display for computed properties
1 parent 3b684d4 commit 64fd857

21 files changed

+73
-69
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2898,7 +2898,7 @@ namespace ts {
28982898

28992899
function getNameOfSymbol(symbol: Symbol): string {
29002900
if (symbol.flags & SymbolFlags.Dynamic) {
2901-
return unescapeIdentifier(symbol.name);
2901+
return `"${escapeString(unescapeIdentifier(symbol.name))}"`;
29022902
}
29032903
if (symbol.declarations && symbol.declarations.length) {
29042904
const declaration = symbol.declarations[0];
@@ -2940,14 +2940,18 @@ namespace ts {
29402940
const needsElementAccess = !isIdentifierStart(firstChar, languageVersion);
29412941

29422942
if (needsElementAccess) {
2943-
writePunctuation(writer, SyntaxKind.OpenBracketToken);
2943+
if (firstChar !== CharacterCodes.openBracket) {
2944+
writePunctuation(writer, SyntaxKind.OpenBracketToken);
2945+
}
29442946
if (isSingleOrDoubleQuote(firstChar)) {
29452947
writer.writeStringLiteral(symbolName);
29462948
}
29472949
else {
29482950
writer.writeSymbol(symbolName, symbol);
29492951
}
2950-
writePunctuation(writer, SyntaxKind.CloseBracketToken);
2952+
if (firstChar !== CharacterCodes.openBracket) {
2953+
writePunctuation(writer, SyntaxKind.CloseBracketToken);
2954+
}
29512955
}
29522956
else {
29532957
writePunctuation(writer, SyntaxKind.DotToken);
@@ -5232,7 +5236,7 @@ namespace ts {
52325236
const nameType = checkComputedPropertyName(<ComputedPropertyName>member.name);
52335237
if (nameType.flags & TypeFlags.StringOrNumberLiteral) {
52345238
// TODO(rbuckton): ESSymbolLiteral
5235-
const memberName = escapeIdentifier((<LiteralType>nameType).text);
5239+
const memberName = (<LiteralType>nameType).text;
52365240
let symbol = symbolTable.get(memberName);
52375241
if (!symbol) {
52385242
symbolTable.set(memberName, symbol = createSymbol(SymbolFlags.Dynamic, memberName));

tests/baselines/reference/computedPropertyNames13_ES5.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class C {
2929
>s : Symbol(s, Decl(computedPropertyNames13_ES5.ts, 0, 3))
3030

3131
static [""]() { }
32-
>"" : Symbol(C[[""]], Decl(computedPropertyNames13_ES5.ts, 8, 14))
32+
>"" : Symbol(C[""], Decl(computedPropertyNames13_ES5.ts, 8, 14))
3333

3434
[0]() { }
35-
>0 : Symbol(C[[0]], Decl(computedPropertyNames13_ES5.ts, 9, 21))
35+
>0 : Symbol(C[0], Decl(computedPropertyNames13_ES5.ts, 9, 21))
3636

3737
[a]() { }
3838
>a : Symbol(a, Decl(computedPropertyNames13_ES5.ts, 2, 3))

tests/baselines/reference/computedPropertyNames13_ES6.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class C {
2929
>s : Symbol(s, Decl(computedPropertyNames13_ES6.ts, 0, 3))
3030

3131
static [""]() { }
32-
>"" : Symbol(C[[""]], Decl(computedPropertyNames13_ES6.ts, 8, 14))
32+
>"" : Symbol(C[""], Decl(computedPropertyNames13_ES6.ts, 8, 14))
3333

3434
[0]() { }
35-
>0 : Symbol(C[[0]], Decl(computedPropertyNames13_ES6.ts, 9, 21))
35+
>0 : Symbol(C[0], Decl(computedPropertyNames13_ES6.ts, 9, 21))
3636

3737
[a]() { }
3838
>a : Symbol(a, Decl(computedPropertyNames13_ES6.ts, 2, 3))

tests/baselines/reference/computedPropertyNames16_ES5.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class C {
3131
>s : Symbol(s, Decl(computedPropertyNames16_ES5.ts, 0, 3))
3232

3333
static set [""](v) { }
34-
>"" : Symbol(C[[""]], Decl(computedPropertyNames16_ES5.ts, 8, 28))
34+
>"" : Symbol(C[""], Decl(computedPropertyNames16_ES5.ts, 8, 28))
3535
>v : Symbol(v, Decl(computedPropertyNames16_ES5.ts, 9, 20))
3636

3737
get [0]() { return 0; }
38-
>0 : Symbol(C[[0]], Decl(computedPropertyNames16_ES5.ts, 9, 26))
38+
>0 : Symbol(C[0], Decl(computedPropertyNames16_ES5.ts, 9, 26))
3939

4040
set [a](v) { }
4141
>a : Symbol(a, Decl(computedPropertyNames16_ES5.ts, 2, 3))

tests/baselines/reference/computedPropertyNames16_ES6.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class C {
3131
>s : Symbol(s, Decl(computedPropertyNames16_ES6.ts, 0, 3))
3232

3333
static set [""](v) { }
34-
>"" : Symbol(C[[""]], Decl(computedPropertyNames16_ES6.ts, 8, 28))
34+
>"" : Symbol(C[""], Decl(computedPropertyNames16_ES6.ts, 8, 28))
3535
>v : Symbol(v, Decl(computedPropertyNames16_ES6.ts, 9, 20))
3636

3737
get [0]() { return 0; }
38-
>0 : Symbol(C[[0]], Decl(computedPropertyNames16_ES6.ts, 9, 26))
38+
>0 : Symbol(C[0], Decl(computedPropertyNames16_ES6.ts, 9, 26))
3939

4040
set [a](v) { }
4141
>a : Symbol(a, Decl(computedPropertyNames16_ES6.ts, 2, 3))

tests/baselines/reference/computedPropertyNames37_ES5.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class C {
1717

1818
// Computed properties
1919
get ["get1"]() { return new Foo }
20-
>"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames37_ES5.ts, 4, 22))
20+
>"get1" : Symbol(C["get1"], Decl(computedPropertyNames37_ES5.ts, 4, 22))
2121
>Foo : Symbol(Foo, Decl(computedPropertyNames37_ES5.ts, 0, 0))
2222

2323
set ["set1"](p: Foo2) { }
24-
>"set1" : Symbol(C[["set1"]], Decl(computedPropertyNames37_ES5.ts, 7, 37))
24+
>"set1" : Symbol(C["set1"], Decl(computedPropertyNames37_ES5.ts, 7, 37))
2525
>p : Symbol(p, Decl(computedPropertyNames37_ES5.ts, 8, 17))
2626
>Foo2 : Symbol(Foo2, Decl(computedPropertyNames37_ES5.ts, 0, 15))
2727
}

tests/baselines/reference/computedPropertyNames37_ES6.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class C {
1717

1818
// Computed properties
1919
get ["get1"]() { return new Foo }
20-
>"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames37_ES6.ts, 4, 22))
20+
>"get1" : Symbol(C["get1"], Decl(computedPropertyNames37_ES6.ts, 4, 22))
2121
>Foo : Symbol(Foo, Decl(computedPropertyNames37_ES6.ts, 0, 0))
2222

2323
set ["set1"](p: Foo2) { }
24-
>"set1" : Symbol(C[["set1"]], Decl(computedPropertyNames37_ES6.ts, 7, 37))
24+
>"set1" : Symbol(C["set1"], Decl(computedPropertyNames37_ES6.ts, 7, 37))
2525
>p : Symbol(p, Decl(computedPropertyNames37_ES6.ts, 8, 17))
2626
>Foo2 : Symbol(Foo2, Decl(computedPropertyNames37_ES6.ts, 0, 15))
2727
}

tests/baselines/reference/computedPropertyNames41_ES5.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ class C {
1717

1818
// Computed properties
1919
static [""]() { return new Foo }
20-
>"" : Symbol(C[[""]], Decl(computedPropertyNames41_ES5.ts, 4, 28))
20+
>"" : Symbol(C[""], Decl(computedPropertyNames41_ES5.ts, 4, 28))
2121
>Foo : Symbol(Foo, Decl(computedPropertyNames41_ES5.ts, 0, 0))
2222
}

tests/baselines/reference/computedPropertyNames41_ES6.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ class C {
1717

1818
// Computed properties
1919
static [""]() { return new Foo }
20-
>"" : Symbol(C[[""]], Decl(computedPropertyNames41_ES6.ts, 4, 28))
20+
>"" : Symbol(C[""], Decl(computedPropertyNames41_ES6.ts, 4, 28))
2121
>Foo : Symbol(Foo, Decl(computedPropertyNames41_ES6.ts, 0, 0))
2222
}

tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ class C {
33
>C : Symbol(C, Decl(computedPropertyNamesSourceMap1_ES5.ts, 0, 0))
44

55
["hello"]() {
6-
>"hello" : Symbol(C[["hello"]], Decl(computedPropertyNamesSourceMap1_ES5.ts, 0, 9))
6+
>"hello" : Symbol(C["hello"], Decl(computedPropertyNamesSourceMap1_ES5.ts, 0, 9))
77

88
debugger;
99
}
1010
get ["goodbye"]() {
11-
>"goodbye" : Symbol(C[["goodbye"]], Decl(computedPropertyNamesSourceMap1_ES5.ts, 3, 5))
11+
>"goodbye" : Symbol(C["goodbye"], Decl(computedPropertyNamesSourceMap1_ES5.ts, 3, 5))
1212

1313
return 0;
1414
}

0 commit comments

Comments
 (0)