diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index c9d3dfc94ba46..6dc6d86fc045e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -843,7 +843,9 @@ module ts { * Symbol. */ export function hasDynamicName(declaration: Declaration): boolean { - return declaration.name && declaration.name.kind === SyntaxKind.ComputedPropertyName; + return declaration.name && + declaration.name.kind === SyntaxKind.ComputedPropertyName && + !isWellKnownSymbolSyntactically((declaration.name).expression); } export function isWellKnownSymbolSyntactically(node: Node): boolean { diff --git a/tests/baselines/reference/parserSymbolProperty1.errors.txt b/tests/baselines/reference/parserSymbolProperty1.errors.txt deleted file mode 100644 index 40f159667035f..0000000000000 --- a/tests/baselines/reference/parserSymbolProperty1.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty1.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - - -==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty1.ts (1 errors) ==== - interface I { - [Symbol.iterator]: string; - ~~~~~~~~~~~~~~~~~ -!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolProperty1.types b/tests/baselines/reference/parserSymbolProperty1.types new file mode 100644 index 0000000000000..ab68b0bc7aceb --- /dev/null +++ b/tests/baselines/reference/parserSymbolProperty1.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty1.ts === +interface I { +>I : I + + [Symbol.iterator]: string; +>Symbol.iterator : Symbol +>Symbol : SymbolConstructor +>iterator : Symbol +} diff --git a/tests/baselines/reference/parserSymbolProperty2.errors.txt b/tests/baselines/reference/parserSymbolProperty2.errors.txt deleted file mode 100644 index fa6f99c2695e3..0000000000000 --- a/tests/baselines/reference/parserSymbolProperty2.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty2.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - - -==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty2.ts (1 errors) ==== - interface I { - [Symbol.unscopables](): string; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolProperty2.types b/tests/baselines/reference/parserSymbolProperty2.types new file mode 100644 index 0000000000000..02ba4c21a8a6d --- /dev/null +++ b/tests/baselines/reference/parserSymbolProperty2.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty2.ts === +interface I { +>I : I + + [Symbol.unscopables](): string; +>Symbol.unscopables : Symbol +>Symbol : SymbolConstructor +>unscopables : Symbol +} diff --git a/tests/baselines/reference/parserSymbolProperty3.errors.txt b/tests/baselines/reference/parserSymbolProperty3.errors.txt deleted file mode 100644 index 2b9ecdc770587..0000000000000 --- a/tests/baselines/reference/parserSymbolProperty3.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty3.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - - -==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty3.ts (1 errors) ==== - declare class C { - [Symbol.unscopables](): string; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolProperty3.types b/tests/baselines/reference/parserSymbolProperty3.types new file mode 100644 index 0000000000000..4f0245cee6f5e --- /dev/null +++ b/tests/baselines/reference/parserSymbolProperty3.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty3.ts === +declare class C { +>C : C + + [Symbol.unscopables](): string; +>Symbol.unscopables : Symbol +>Symbol : SymbolConstructor +>unscopables : Symbol +} diff --git a/tests/baselines/reference/parserSymbolProperty4.errors.txt b/tests/baselines/reference/parserSymbolProperty4.errors.txt deleted file mode 100644 index 2405651b0b184..0000000000000 --- a/tests/baselines/reference/parserSymbolProperty4.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty4.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - - -==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty4.ts (1 errors) ==== - declare class C { - [Symbol.isRegExp]: string; - ~~~~~~~~~~~~~~~~~ -!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolProperty4.types b/tests/baselines/reference/parserSymbolProperty4.types new file mode 100644 index 0000000000000..9fcd6c4a29edb --- /dev/null +++ b/tests/baselines/reference/parserSymbolProperty4.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty4.ts === +declare class C { +>C : C + + [Symbol.isRegExp]: string; +>Symbol.isRegExp : Symbol +>Symbol : SymbolConstructor +>isRegExp : Symbol +} diff --git a/tests/baselines/reference/parserSymbolProperty5.errors.txt b/tests/baselines/reference/parserSymbolProperty5.errors.txt deleted file mode 100644 index 8eb85a293f54d..0000000000000 --- a/tests/baselines/reference/parserSymbolProperty5.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty5.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - - -==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty5.ts (1 errors) ==== - class C { - [Symbol.isRegExp]: string; - ~~~~~~~~~~~~~~~~~ -!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolProperty5.types b/tests/baselines/reference/parserSymbolProperty5.types new file mode 100644 index 0000000000000..1cdaa6ec694da --- /dev/null +++ b/tests/baselines/reference/parserSymbolProperty5.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty5.ts === +class C { +>C : C + + [Symbol.isRegExp]: string; +>Symbol.isRegExp : Symbol +>Symbol : SymbolConstructor +>isRegExp : Symbol +} diff --git a/tests/baselines/reference/parserSymbolProperty6.errors.txt b/tests/baselines/reference/parserSymbolProperty6.errors.txt deleted file mode 100644 index 8fde6aac4a88e..0000000000000 --- a/tests/baselines/reference/parserSymbolProperty6.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty6.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - - -==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty6.ts (1 errors) ==== - class C { - [Symbol.toStringTag]: string = ""; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolProperty6.types b/tests/baselines/reference/parserSymbolProperty6.types new file mode 100644 index 0000000000000..7f14f36d28d16 --- /dev/null +++ b/tests/baselines/reference/parserSymbolProperty6.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty6.ts === +class C { +>C : C + + [Symbol.toStringTag]: string = ""; +>Symbol.toStringTag : Symbol +>Symbol : SymbolConstructor +>toStringTag : Symbol +} diff --git a/tests/baselines/reference/parserSymbolProperty7.errors.txt b/tests/baselines/reference/parserSymbolProperty7.errors.txt deleted file mode 100644 index b55bbaa11aeb4..0000000000000 --- a/tests/baselines/reference/parserSymbolProperty7.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty7.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - - -==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty7.ts (1 errors) ==== - class C { - [Symbol.toStringTag](): void { } - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolProperty7.types b/tests/baselines/reference/parserSymbolProperty7.types new file mode 100644 index 0000000000000..ce62cd9349821 --- /dev/null +++ b/tests/baselines/reference/parserSymbolProperty7.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty7.ts === +class C { +>C : C + + [Symbol.toStringTag](): void { } +>Symbol.toStringTag : Symbol +>Symbol : SymbolConstructor +>toStringTag : Symbol +} diff --git a/tests/baselines/reference/parserSymbolProperty8.errors.txt b/tests/baselines/reference/parserSymbolProperty8.errors.txt deleted file mode 100644 index c37219682df65..0000000000000 --- a/tests/baselines/reference/parserSymbolProperty8.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty8.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - - -==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty8.ts (1 errors) ==== - var x: { - [Symbol.toPrimitive](): string - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolProperty8.types b/tests/baselines/reference/parserSymbolProperty8.types new file mode 100644 index 0000000000000..cc3a20af9be16 --- /dev/null +++ b/tests/baselines/reference/parserSymbolProperty8.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty8.ts === +var x: { +>x : {} + + [Symbol.toPrimitive](): string +>Symbol.toPrimitive : Symbol +>Symbol : SymbolConstructor +>toPrimitive : Symbol +} diff --git a/tests/baselines/reference/parserSymbolProperty9.errors.txt b/tests/baselines/reference/parserSymbolProperty9.errors.txt deleted file mode 100644 index b229d29b1b444..0000000000000 --- a/tests/baselines/reference/parserSymbolProperty9.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty9.ts(2,5): error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - - -==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty9.ts (1 errors) ==== - var x: { - [Symbol.toPrimitive]: string - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2464: A computed property name must be of type 'string', 'number', or 'any'. - } \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolProperty9.types b/tests/baselines/reference/parserSymbolProperty9.types new file mode 100644 index 0000000000000..77746283990ee --- /dev/null +++ b/tests/baselines/reference/parserSymbolProperty9.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty9.ts === +var x: { +>x : {} + + [Symbol.toPrimitive]: string +>Symbol.toPrimitive : Symbol +>Symbol : SymbolConstructor +>toPrimitive : Symbol +}