Clarified error message; extended error to identifier end

Lengthening the reported error length to include all of the identifier necessitates scanning for all of the identifier. I also reset the `pos` after so other identifier scanning still happens.
This commit is contained in:
Josh Goldberg
2018-12-06 11:17:06 -08:00
parent 31fca3af4d
commit a211184347
13 changed files with 241 additions and 50 deletions

View File

@@ -1011,7 +1011,7 @@
"category": "Message",
"code": 1350
},
"An identifier cannot follow a numeric literal.": {
"An identifier or keyword cannot immediately follow a numeric literal.": {
"category": "Error",
"code": 1351
},

View File

@@ -991,9 +991,14 @@ namespace ts {
}
function checkForIdentifierStartAfterNumericLiteral() {
if (isIdentifierStart(text.charCodeAt(pos), languageVersion)) {
error(Diagnostics.An_identifier_cannot_follow_a_numeric_literal, pos, 1);
if (!isIdentifierStart(text.charCodeAt(pos), languageVersion)) {
return;
}
const identifierStart = pos;
const { length } = scanIdentifierParts();
error(Diagnostics.An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal, identifierStart, length);
pos = identifierStart;
}
function scanOctalDigits(): number {