fix(45114): throw an error when using '#' as an identifier (#45124)

This commit is contained in:
Oleksandr T
2021-07-26 21:39:17 +03:00
committed by GitHub
parent ba226167bc
commit 11c7daef62
6 changed files with 111 additions and 2 deletions

View File

@@ -2047,8 +2047,15 @@ namespace ts {
pos++;
return token = SyntaxKind.Unknown;
}
pos++;
scanIdentifier(codePointAt(text, pos), languageVersion);
if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) {
pos++;
scanIdentifier(codePointAt(text, pos), languageVersion);
}
else {
tokenValue = String.fromCharCode(codePointAt(text, pos));
error(Diagnostics.Invalid_character, pos++, charSize(ch));
}
return token = SyntaxKind.PrivateIdentifier;
default:
const identifierKind = scanIdentifier(ch, languageVersion);