Skip to content

Commit 07f3641

Browse files
committed
Update hasDynamicName to take well known symbols into account
1 parent d788624 commit 07f3641

19 files changed

+84
-82
lines changed

src/compiler/utilities.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,9 @@ module ts {
843843
* Symbol.
844844
*/
845845
export function hasDynamicName(declaration: Declaration): boolean {
846-
return declaration.name && declaration.name.kind === SyntaxKind.ComputedPropertyName;
846+
return declaration.name &&
847+
declaration.name.kind === SyntaxKind.ComputedPropertyName &&
848+
!isWellKnownSymbolSyntactically((<ComputedPropertyName>declaration.name).expression);
847849
}
848850

849851
export function isWellKnownSymbolSyntactically(node: Node): boolean {

tests/baselines/reference/parserSymbolProperty1.errors.txt

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty1.ts ===
2+
interface I {
3+
>I : I
4+
5+
[Symbol.iterator]: string;
6+
>Symbol.iterator : Symbol
7+
>Symbol : SymbolConstructor
8+
>iterator : Symbol
9+
}

tests/baselines/reference/parserSymbolProperty2.errors.txt

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty2.ts ===
2+
interface I {
3+
>I : I
4+
5+
[Symbol.unscopables](): string;
6+
>Symbol.unscopables : Symbol
7+
>Symbol : SymbolConstructor
8+
>unscopables : Symbol
9+
}

tests/baselines/reference/parserSymbolProperty3.errors.txt

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty3.ts ===
2+
declare class C {
3+
>C : C
4+
5+
[Symbol.unscopables](): string;
6+
>Symbol.unscopables : Symbol
7+
>Symbol : SymbolConstructor
8+
>unscopables : Symbol
9+
}

tests/baselines/reference/parserSymbolProperty4.errors.txt

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty4.ts ===
2+
declare class C {
3+
>C : C
4+
5+
[Symbol.isRegExp]: string;
6+
>Symbol.isRegExp : Symbol
7+
>Symbol : SymbolConstructor
8+
>isRegExp : Symbol
9+
}

tests/baselines/reference/parserSymbolProperty5.errors.txt

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty5.ts ===
2+
class C {
3+
>C : C
4+
5+
[Symbol.isRegExp]: string;
6+
>Symbol.isRegExp : Symbol
7+
>Symbol : SymbolConstructor
8+
>isRegExp : Symbol
9+
}

tests/baselines/reference/parserSymbolProperty6.errors.txt

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty6.ts ===
2+
class C {
3+
>C : C
4+
5+
[Symbol.toStringTag]: string = "";
6+
>Symbol.toStringTag : Symbol
7+
>Symbol : SymbolConstructor
8+
>toStringTag : Symbol
9+
}

tests/baselines/reference/parserSymbolProperty7.errors.txt

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty7.ts ===
2+
class C {
3+
>C : C
4+
5+
[Symbol.toStringTag](): void { }
6+
>Symbol.toStringTag : Symbol
7+
>Symbol : SymbolConstructor
8+
>toStringTag : Symbol
9+
}

tests/baselines/reference/parserSymbolProperty8.errors.txt

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty8.ts ===
2+
var x: {
3+
>x : {}
4+
5+
[Symbol.toPrimitive](): string
6+
>Symbol.toPrimitive : Symbol
7+
>Symbol : SymbolConstructor
8+
>toPrimitive : Symbol
9+
}

tests/baselines/reference/parserSymbolProperty9.errors.txt

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty9.ts ===
2+
var x: {
3+
>x : {}
4+
5+
[Symbol.toPrimitive]: string
6+
>Symbol.toPrimitive : Symbol
7+
>Symbol : SymbolConstructor
8+
>toPrimitive : Symbol
9+
}

0 commit comments

Comments
 (0)