Skip to content

Commit 4be0670

Browse files
committed
Unify symboles for template literals in computed properties
1 parent 9868be6 commit 4be0670

14 files changed

+14
-1
lines changed

src/compiler/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2499,7 +2499,7 @@ namespace ts {
24992499
}
25002500

25012501
export function isLiteralComputedPropertyDeclarationName(node: Node) {
2502-
return (node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) &&
2502+
return isStringOrNumericLiteralLike(node) &&
25032503
node.parent.kind === SyntaxKind.ComputedPropertyName &&
25042504
isDeclaration(node.parent.parent);
25052505
}

tests/baselines/reference/computedPropertyNames10_ES5.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ var v = {
5050

5151
[`hello bye`]() { },
5252
>[`hello bye`] : Symbol([`hello bye`], Decl(computedPropertyNames10_ES5.ts, 12, 22))
53+
>`hello bye` : Symbol([`hello bye`], Decl(computedPropertyNames10_ES5.ts, 12, 22))
5354

5455
[`hello ${a} bye`]() { }
5556
>[`hello ${a} bye`] : Symbol([`hello ${a} bye`], Decl(computedPropertyNames10_ES5.ts, 13, 24))

tests/baselines/reference/computedPropertyNames10_ES6.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ var v = {
5050

5151
[`hello bye`]() { },
5252
>[`hello bye`] : Symbol([`hello bye`], Decl(computedPropertyNames10_ES6.ts, 12, 22))
53+
>`hello bye` : Symbol([`hello bye`], Decl(computedPropertyNames10_ES6.ts, 12, 22))
5354

5455
[`hello ${a} bye`]() { }
5556
>[`hello ${a} bye`] : Symbol([`hello ${a} bye`], Decl(computedPropertyNames10_ES6.ts, 13, 24))

tests/baselines/reference/computedPropertyNames11_ES5.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ var v = {
5454

5555
set [`hello bye`](v) { },
5656
>[`hello bye`] : Symbol([`hello bye`], Decl(computedPropertyNames11_ES5.ts, 12, 36))
57+
>`hello bye` : Symbol([`hello bye`], Decl(computedPropertyNames11_ES5.ts, 12, 36))
5758
>v : Symbol(v, Decl(computedPropertyNames11_ES5.ts, 13, 22))
5859

5960
get [`hello ${a} bye`]() { return 0; }

tests/baselines/reference/computedPropertyNames11_ES6.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ var v = {
5454

5555
set [`hello bye`](v) { },
5656
>[`hello bye`] : Symbol([`hello bye`], Decl(computedPropertyNames11_ES6.ts, 12, 36))
57+
>`hello bye` : Symbol([`hello bye`], Decl(computedPropertyNames11_ES6.ts, 12, 36))
5758
>v : Symbol(v, Decl(computedPropertyNames11_ES6.ts, 13, 22))
5859

5960
get [`hello ${a} bye`]() { return 0; }

tests/baselines/reference/computedPropertyNames12_ES5.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class C {
5252

5353
[`hello bye`] = 0;
5454
>[`hello bye`] : Symbol(C[`hello bye`], Decl(computedPropertyNames12_ES5.ts, 12, 31))
55+
>`hello bye` : Symbol(C[`hello bye`], Decl(computedPropertyNames12_ES5.ts, 12, 31))
5556

5657
static [`hello ${a} bye`] = 0
5758
>[`hello ${a} bye`] : Symbol(C[`hello ${a} bye`], Decl(computedPropertyNames12_ES5.ts, 13, 22))

tests/baselines/reference/computedPropertyNames12_ES6.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class C {
5252

5353
[`hello bye`] = 0;
5454
>[`hello bye`] : Symbol(C[`hello bye`], Decl(computedPropertyNames12_ES6.ts, 12, 31))
55+
>`hello bye` : Symbol(C[`hello bye`], Decl(computedPropertyNames12_ES6.ts, 12, 31))
5556

5657
static [`hello ${a} bye`] = 0
5758
>[`hello ${a} bye`] : Symbol(C[`hello ${a} bye`], Decl(computedPropertyNames12_ES6.ts, 13, 22))

tests/baselines/reference/computedPropertyNames13_ES5.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class C {
5050

5151
[`hello bye`]() { }
5252
>[`hello bye`] : Symbol(C[`hello bye`], Decl(computedPropertyNames13_ES5.ts, 12, 28))
53+
>`hello bye` : Symbol(C[`hello bye`], Decl(computedPropertyNames13_ES5.ts, 12, 28))
5354

5455
static [`hello ${a} bye`]() { }
5556
>[`hello ${a} bye`] : Symbol(C[`hello ${a} bye`], Decl(computedPropertyNames13_ES5.ts, 13, 23))

tests/baselines/reference/computedPropertyNames13_ES6.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class C {
5050

5151
[`hello bye`]() { }
5252
>[`hello bye`] : Symbol(C[`hello bye`], Decl(computedPropertyNames13_ES6.ts, 12, 28))
53+
>`hello bye` : Symbol(C[`hello bye`], Decl(computedPropertyNames13_ES6.ts, 12, 28))
5354

5455
static [`hello ${a} bye`]() { }
5556
>[`hello ${a} bye`] : Symbol(C[`hello ${a} bye`], Decl(computedPropertyNames13_ES6.ts, 13, 23))

tests/baselines/reference/computedPropertyNames16_ES5.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class C {
5454

5555
set [`hello bye`](v) { }
5656
>[`hello bye`] : Symbol(C[`hello bye`], Decl(computedPropertyNames16_ES5.ts, 12, 42))
57+
>`hello bye` : Symbol(C[`hello bye`], Decl(computedPropertyNames16_ES5.ts, 12, 42))
5758
>v : Symbol(v, Decl(computedPropertyNames16_ES5.ts, 13, 22))
5859

5960
get [`hello ${a} bye`]() { return 0; }

tests/baselines/reference/computedPropertyNames16_ES6.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class C {
5454

5555
set [`hello bye`](v) { }
5656
>[`hello bye`] : Symbol(C[`hello bye`], Decl(computedPropertyNames16_ES6.ts, 12, 42))
57+
>`hello bye` : Symbol(C[`hello bye`], Decl(computedPropertyNames16_ES6.ts, 12, 42))
5758
>v : Symbol(v, Decl(computedPropertyNames16_ES6.ts, 13, 22))
5859

5960
get [`hello ${a} bye`]() { return 0; }

tests/baselines/reference/computedPropertyNames4_ES5.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ var v = {
5252

5353
[`hello bye`]: 0,
5454
>[`hello bye`] : Symbol([`hello bye`], Decl(computedPropertyNames4_ES5.ts, 12, 19))
55+
>`hello bye` : Symbol([`hello bye`], Decl(computedPropertyNames4_ES5.ts, 12, 19))
5556

5657
[`hello ${a} bye`]: 0
5758
>[`hello ${a} bye`] : Symbol([`hello ${a} bye`], Decl(computedPropertyNames4_ES5.ts, 13, 21))

tests/baselines/reference/computedPropertyNames4_ES6.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ var v = {
5252

5353
[`hello bye`]: 0,
5454
>[`hello bye`] : Symbol([`hello bye`], Decl(computedPropertyNames4_ES6.ts, 12, 19))
55+
>`hello bye` : Symbol([`hello bye`], Decl(computedPropertyNames4_ES6.ts, 12, 19))
5556

5657
[`hello ${a} bye`]: 0
5758
>[`hello ${a} bye`] : Symbol([`hello ${a} bye`], Decl(computedPropertyNames4_ES6.ts, 13, 21))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
=== tests/cases/compiler/computerPropertiesInES5ShouldBeTransformed.ts ===
22
const b = ({ [`key`]: renamed }) => renamed;
33
>b : Symbol(b, Decl(computerPropertiesInES5ShouldBeTransformed.ts, 0, 5))
4+
>`key` : Symbol(renamed, Decl(computerPropertiesInES5ShouldBeTransformed.ts, 0, 12))
45
>renamed : Symbol(renamed, Decl(computerPropertiesInES5ShouldBeTransformed.ts, 0, 12))
56
>renamed : Symbol(renamed, Decl(computerPropertiesInES5ShouldBeTransformed.ts, 0, 12))
67

0 commit comments

Comments
 (0)