mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Update hasDynamicName to take well known symbols into account
This commit is contained in:
@@ -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((<ComputedPropertyName>declaration.name).expression);
|
||||
}
|
||||
|
||||
export function isWellKnownSymbolSyntactically(node: Node): boolean {
|
||||
|
||||
@@ -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'.
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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'.
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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'.
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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'.
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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'.
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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'.
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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'.
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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'.
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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'.
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user