@@ -886,7 +886,7 @@ namespace ts {
886886
887887 /** Invokes the provided callback then unconditionally restores the parser to the state it
888888 * was in immediately prior to invoking the callback. The result of invoking the callback
889- * is returned from this function.
889+ * is returned from this function.
890890 */
891891 function lookAhead < T > ( callback : ( ) => T ) : T {
892892 return speculationHelper ( callback , /*isLookAhead*/ true ) ;
@@ -4988,7 +4988,7 @@ namespace ts {
49884988
49894989 if ( token === SyntaxKind . ConstKeyword && permitInvalidConstAsModifier ) {
49904990 // We need to ensure that any subsequent modifiers appear on the same line
4991- // so that when 'const' is a standalone declaration, we don't issue an error.
4991+ // so that when 'const' is a standalone declaration, we don't issue an error.
49924992 if ( ! tryParse ( nextTokenIsOnSameLineAndCanFollowModifier ) ) {
49934993 break ;
49944994 }
@@ -5251,7 +5251,7 @@ namespace ts {
52515251 node . decorators = decorators ;
52525252 setModifiers ( node , modifiers ) ;
52535253 if ( token === SyntaxKind . GlobalKeyword ) {
5254- // parse 'global' as name of global scope augmentation
5254+ // parse 'global' as name of global scope augmentation
52555255 node . name = parseIdentifier ( ) ;
52565256 node . flags |= NodeFlags . GlobalAugmentation ;
52575257 }
@@ -6087,7 +6087,7 @@ namespace ts {
60876087 atToken . end = scanner . getTextPos ( ) ;
60886088 nextJSDocToken ( ) ;
60896089
6090- const tagName = parseJSDocIdentifier ( ) ;
6090+ const tagName = parseJSDocIdentifierName ( ) ;
60916091 if ( ! tagName ) {
60926092 return ;
60936093 }
@@ -6150,7 +6150,7 @@ namespace ts {
61506150 let isBracketed : boolean ;
61516151 // Looking for something like '[foo]' or 'foo'
61526152 if ( parseOptionalToken ( SyntaxKind . OpenBracketToken ) ) {
6153- name = parseJSDocIdentifier ( ) ;
6153+ name = parseJSDocIdentifierName ( ) ;
61546154 isBracketed = true ;
61556155
61566156 // May have an optional default, e.g. '[foo = 42]'
@@ -6160,8 +6160,8 @@ namespace ts {
61606160
61616161 parseExpected ( SyntaxKind . CloseBracketToken ) ;
61626162 }
6163- else if ( token === SyntaxKind . Identifier || isTSOnlyKeyword ( token ) ) {
6164- name = parseJSDocIdentifier ( ) ;
6163+ else if ( tokenIsIdentifierOrKeyword ( token ) ) {
6164+ name = parseJSDocIdentifierName ( ) ;
61656165 }
61666166
61676167 if ( ! name ) {
@@ -6225,7 +6225,7 @@ namespace ts {
62256225 typeParameters . pos = scanner . getStartPos ( ) ;
62266226
62276227 while ( true ) {
6228- const name = parseJSDocIdentifier ( ) ;
6228+ const name = parseJSDocIdentifierName ( ) ;
62296229 if ( ! name ) {
62306230 parseErrorAtPosition ( scanner . getStartPos ( ) , 0 , Diagnostics . Identifier_expected ) ;
62316231 return undefined ;
@@ -6258,8 +6258,12 @@ namespace ts {
62586258 return token = scanner . scanJSDocToken ( ) ;
62596259 }
62606260
6261- function parseJSDocIdentifier ( ) : Identifier {
6262- if ( token !== SyntaxKind . Identifier && ! isTSOnlyKeyword ( token ) ) {
6261+ function parseJSDocIdentifierName ( ) : Identifier {
6262+ return createJSDocIdentifier ( tokenIsIdentifierOrKeyword ( token ) ) ;
6263+ }
6264+
6265+ function createJSDocIdentifier ( isIdentifier : boolean ) : Identifier {
6266+ if ( ! isIdentifier ) {
62636267 parseErrorAtCurrentToken ( Diagnostics . Identifier_expected ) ;
62646268 return undefined ;
62656269 }
0 commit comments