Remove error on invalid jsdoc tokens#32769
Conversation
In JSDoc: 1. In the scanner, don't issue an error, even for invalid identifiers. 2. In the binder, don't issue an error for reserved (but otherwise valid) identifiers. /** * Example of 1: "\" * Example of 2: @Private */
| return token = getIdentifierToken(); | ||
| } | ||
| error(Diagnostics.Invalid_character); | ||
| pos++; |
There was a problem hiding this comment.
Should we also be ignoring errors on invalid Unicode escapes, like \u{1010101010}? That'll require passing a flag into scanIdentifierParts and the other callers of scanExtendedUnicodeEscape.
There was a problem hiding this comment.
I can't get any error with the current code! I compared
/**
* unicode-escape = \u{abcdefghi} -- should not have error for invalid unicode escape
*/
var hi = "\u{00fa}\u{abcdefghi}"There's an error for the second abcdefghi but not the first.
I'll add a test to make sure it stays that way.
There was a problem hiding this comment.
You should also check, just in case, the scenario when the unicode escape is the second character in the identifier eg, q\u{abcdefghi} - The first character is handled inline in scanJsDocToken with a non-erroring peek (so it can fallback to the Invalid character error you just removed), while the second character (and beyond) is handled in scanIdentifierParts which, could always behave different.
In JSDoc:
identifiers.
I'm not sure of the fix in the binder. It might be better to avoid setting originalKeywordKind in the parser for bad identifiers in jsdoc, but that seems wrong because the jsdoc code path really should behave just like the normal one so that it's easy to remove later.
Fixes #32756