@@ -2052,17 +2052,38 @@ namespace ts {
2052
2052
return token = SyntaxKind . Unknown ;
2053
2053
}
2054
2054
2055
- if ( isIdentifierStart ( codePointAt ( text , pos + 1 ) , languageVersion ) ) {
2055
+ const charAfterHash = codePointAt ( text , pos + 1 ) ;
2056
+ if ( charAfterHash === CharacterCodes . backslash ) {
2057
+ pos ++
2058
+ const extendedCookedChar = peekExtendedUnicodeEscape ( ) ;
2059
+ if ( extendedCookedChar >= 0 && isIdentifierStart ( extendedCookedChar , languageVersion ) ) {
2060
+ pos += 3 ;
2061
+ tokenFlags |= TokenFlags . ExtendedUnicodeEscape ;
2062
+ tokenValue = "#" + scanExtendedUnicodeEscape ( ) + scanIdentifierParts ( ) ;
2063
+ return token = SyntaxKind . PrivateIdentifier ;
2064
+ }
2065
+
2066
+ const cookedChar = peekUnicodeEscape ( ) ;
2067
+ if ( cookedChar >= 0 && isIdentifierStart ( cookedChar , languageVersion ) ) {
2068
+ pos += 6 ;
2069
+ tokenFlags |= TokenFlags . UnicodeEscape ;
2070
+ tokenValue = "#" + String . fromCharCode ( cookedChar ) + scanIdentifierParts ( ) ;
2071
+ return token = SyntaxKind . PrivateIdentifier ;
2072
+ }
2073
+ pos -- ;
2074
+ }
2075
+
2076
+ if ( isIdentifierStart ( charAfterHash , languageVersion ) ) {
2056
2077
pos ++ ;
2057
2078
// We're relying on scanIdentifier's behavior and adjusting the token kind after the fact.
2058
2079
// Notably absent from this block is the fact that calling a function named "scanIdentifier",
2059
2080
// but identifiers don't include '#', and that function doesn't deal with it at all.
2060
2081
// This works because 'scanIdentifier' tries to reuse source characters and builds up substrings;
2061
2082
// however, it starts at the 'tokenPos' which includes the '#', and will "accidentally" prepend the '#' for us.
2062
- scanIdentifier ( codePointAt ( text , pos ) , languageVersion ) ;
2083
+ scanIdentifier ( charAfterHash , languageVersion ) ;
2063
2084
}
2064
2085
else {
2065
- tokenValue = String . fromCharCode ( codePointAt ( text , pos ) ) ;
2086
+ tokenValue = "#" ;
2066
2087
error ( Diagnostics . Invalid_character , pos ++ , charSize ( ch ) ) ;
2067
2088
}
2068
2089
return token = SyntaxKind . PrivateIdentifier ;
0 commit comments