File tree Expand file tree Collapse file tree 5 files changed +18
-7
lines changed
tests/baselines/reference Expand file tree Collapse file tree 5 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -87,13 +87,18 @@ module ts {
8787 if ( symbolKind & SymbolFlags . Value && ! symbol . valueDeclaration ) symbol . valueDeclaration = node ;
8888 }
8989
90- // Should not be called on a declaration with a computed property name.
90+ // Should not be called on a declaration with a computed property name,
91+ // unless it is a well known Symbol.
9192 function getDeclarationName ( node : Declaration ) : string {
9293 if ( node . name ) {
9394 if ( node . kind === SyntaxKind . ModuleDeclaration && node . name . kind === SyntaxKind . StringLiteral ) {
9495 return '"' + ( < LiteralExpression > node . name ) . text + '"' ;
9596 }
96- Debug . assert ( ! hasDynamicName ( node ) ) ;
97+ if ( node . name . kind === SyntaxKind . ComputedPropertyName ) {
98+ var nameExpression = ( < ComputedPropertyName > node . name ) . expression ;
99+ Debug . assert ( isWellKnownSymbolSyntactically ( nameExpression ) ) ;
100+ return "__@" + ( < PropertyAccessExpression > nameExpression ) . name . text ;
101+ }
97102 return ( < Identifier | LiteralExpression > node . name ) . text ;
98103 }
99104 switch ( node . kind ) {
Original file line number Diff line number Diff line change @@ -706,9 +706,15 @@ module ts {
706706 return type;
707707 }
708708
709- // A reserved member name starts with two underscores followed by a non-underscore
709+ // A reserved member name starts with two underscores, but the third character cannot be an underscore
710+ // or the @ symbol. A third underscore indicates an escaped form of an identifer that started
711+ // with at least two underscores. The @ character indicates that the name is denoted by a well known ES
712+ // Symbol instance.
710713 function isReservedMemberName(name: string) {
711- return name.charCodeAt(0) === CharacterCodes._ && name.charCodeAt(1) === CharacterCodes._ && name.charCodeAt(2) !== CharacterCodes._;
714+ return name.charCodeAt(0) === CharacterCodes._ &&
715+ name.charCodeAt(1) === CharacterCodes._ &&
716+ name.charCodeAt(2) !== CharacterCodes._ &&
717+ name.charCodeAt(2) !== CharacterCodes.at;
712718 }
713719
714720 function getNamedMembers(members: SymbolTable): Symbol[] {
Original file line number Diff line number Diff line change @@ -848,7 +848,7 @@ module ts {
848848 ! isWellKnownSymbolSyntactically ( ( < ComputedPropertyName > declaration . name ) . expression ) ;
849849 }
850850
851- export function isWellKnownSymbolSyntactically ( node : Node ) : boolean {
851+ export function isWellKnownSymbolSyntactically ( node : Expression ) : boolean {
852852 return node . kind === SyntaxKind . PropertyAccessExpression && isESSymbolIdentifier ( ( < PropertyAccessExpression > node ) . expression ) ;
853853 }
854854
Original file line number Diff line number Diff line change 11=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty8.ts ===
22var x: {
3- >x : {}
3+ >x : { [Symbol.toPrimitive](): string; }
44
55 [Symbol.toPrimitive](): string
66>Symbol.toPrimitive : Symbol
Original file line number Diff line number Diff line change 11=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty9.ts ===
22var x: {
3- >x : {}
3+ >x : { [Symbol.toPrimitive]: string; }
44
55 [Symbol.toPrimitive]: string
66>Symbol.toPrimitive : Symbol
You can’t perform that action at this time.
0 commit comments