File tree 5 files changed +18
-7
lines changed
tests/baselines/reference
5 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -87,13 +87,18 @@ module ts {
87
87
if ( symbolKind & SymbolFlags . Value && ! symbol . valueDeclaration ) symbol . valueDeclaration = node ;
88
88
}
89
89
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.
91
92
function getDeclarationName ( node : Declaration ) : string {
92
93
if ( node . name ) {
93
94
if ( node . kind === SyntaxKind . ModuleDeclaration && node . name . kind === SyntaxKind . StringLiteral ) {
94
95
return '"' + ( < LiteralExpression > node . name ) . text + '"' ;
95
96
}
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
+ }
97
102
return ( < Identifier | LiteralExpression > node . name ) . text ;
98
103
}
99
104
switch ( node . kind ) {
Original file line number Diff line number Diff line change @@ -706,9 +706,15 @@ module ts {
706
706
return type;
707
707
}
708
708
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.
710
713
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;
712
718
}
713
719
714
720
function getNamedMembers(members: SymbolTable): Symbol[] {
Original file line number Diff line number Diff line change @@ -848,7 +848,7 @@ module ts {
848
848
! isWellKnownSymbolSyntactically ( ( < ComputedPropertyName > declaration . name ) . expression ) ;
849
849
}
850
850
851
- export function isWellKnownSymbolSyntactically ( node : Node ) : boolean {
851
+ export function isWellKnownSymbolSyntactically ( node : Expression ) : boolean {
852
852
return node . kind === SyntaxKind . PropertyAccessExpression && isESSymbolIdentifier ( ( < PropertyAccessExpression > node ) . expression ) ;
853
853
}
854
854
Original file line number Diff line number Diff line change 1
1
=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty8.ts ===
2
2
var x: {
3
- >x : {}
3
+ >x : { [Symbol.toPrimitive](): string; }
4
4
5
5
[Symbol.toPrimitive](): string
6
6
>Symbol.toPrimitive : Symbol
Original file line number Diff line number Diff line change 1
1
=== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolProperty9.ts ===
2
2
var x: {
3
- >x : {}
3
+ >x : { [Symbol.toPrimitive]: string; }
4
4
5
5
[Symbol.toPrimitive]: string
6
6
>Symbol.toPrimitive : Symbol
You can’t perform that action at this time.
0 commit comments