File tree Expand file tree Collapse file tree 4 files changed +19
-0
lines changed Expand file tree Collapse file tree 4 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1335,6 +1335,7 @@ namespace ts {
1335
1335
if ( token ( ) !== SyntaxKind . Identifier ) {
1336
1336
node . originalKeywordKind = token ( ) ;
1337
1337
}
1338
+ node . isPrivateName = ! ! ( scanner . getTokenFlags ( ) & TokenFlags . PrivateName ) ;
1338
1339
node . escapedText = escapeLeadingUnderscores ( internIdentifier ( scanner . getTokenValue ( ) ) ) ;
1339
1340
nextToken ( ) ;
1340
1341
return finishNode ( node ) ;
Original file line number Diff line number Diff line change @@ -1723,6 +1723,21 @@ namespace ts {
1723
1723
error ( Diagnostics . Invalid_character ) ;
1724
1724
pos ++ ;
1725
1725
return token = SyntaxKind . Unknown ;
1726
+ case CharacterCodes . hash :
1727
+ pos ++ ;
1728
+ if ( isIdentifierStart ( ch = text . charCodeAt ( pos ) , languageVersion ) ) {
1729
+ tokenFlags |= TokenFlags . PrivateName ;
1730
+ pos ++ ;
1731
+ while ( pos < end && isIdentifierPart ( ch = text . charCodeAt ( pos ) , languageVersion ) ) pos ++ ;
1732
+ tokenValue = text . substring ( tokenPos , pos ) ;
1733
+ if ( ch === CharacterCodes . backslash ) {
1734
+ tokenValue += scanIdentifierParts ( ) ;
1735
+ }
1736
+ return token = SyntaxKind . Identifier ;
1737
+ }
1738
+ error ( Diagnostics . Invalid_character ) ;
1739
+ pos ++ ;
1740
+ return token = SyntaxKind . Unknown ;
1726
1741
default :
1727
1742
if ( isIdentifierStart ( ch , languageVersion ) ) {
1728
1743
pos ++ ;
Original file line number Diff line number Diff line change @@ -680,6 +680,7 @@ namespace ts {
680
680
*/
681
681
escapedText : __String ;
682
682
originalKeywordKind ?: SyntaxKind ; // Original syntaxKind which get set so that we can report an error later
683
+ isPrivateName : boolean ; // is private name like `this.#foo`
683
684
/*@internal */ autoGenerateFlags ?: GeneratedIdentifierFlags ; // Specifies whether to auto-generate the text for an identifier.
684
685
/*@internal */ autoGenerateId ?: number ; // Ensures unique generated identifiers get unique names, but clones get the same name.
685
686
isInJSDocNamespace ?: boolean ; // if the node is a member in a JSDoc namespace
@@ -1555,6 +1556,7 @@ namespace ts {
1555
1556
BinarySpecifier = 1 << 7 , // e.g. `0b0110010000000000`
1556
1557
OctalSpecifier = 1 << 8 , // e.g. `0o777`
1557
1558
ContainsSeparator = 1 << 9 , // e.g. `0b1100_0101`
1559
+ PrivateName = 1 << 10 , // e.g. `#foo`
1558
1560
BinaryOrOctalSpecifier = BinarySpecifier | OctalSpecifier ,
1559
1561
NumericLiteralFlags = Scientific | Octal | HexSpecifier | BinarySpecifier | OctalSpecifier | ContainsSeparator
1560
1562
}
Original file line number Diff line number Diff line change @@ -347,6 +347,7 @@ namespace ts {
347
347
public kind : SyntaxKind . Identifier ;
348
348
public escapedText : __String ;
349
349
public symbol : Symbol ;
350
+ public isPrivateName : boolean ;
350
351
public autoGenerateFlags : GeneratedIdentifierFlags ;
351
352
_primaryExpressionBrand : any ;
352
353
_memberExpressionBrand : any ;
You can’t perform that action at this time.
0 commit comments