@@ -6365,17 +6365,14 @@ namespace ts {
63656365 indent += text . length ;
63666366 }
63676367
6368- let t = nextJSDocToken ( ) ;
6369- while ( t === SyntaxKind . WhitespaceTrivia ) {
6370- t = nextJSDocToken ( ) ;
6371- }
6372- if ( t === SyntaxKind . NewLineTrivia ) {
6368+ nextJSDocToken ( ) ;
6369+ while ( parseOptionalJsdoc ( SyntaxKind . WhitespaceTrivia ) ) ;
6370+ if ( parseOptionalJsdoc ( SyntaxKind . NewLineTrivia ) ) {
63736371 state = JSDocState . BeginningOfLine ;
63746372 indent = 0 ;
6375- t = nextJSDocToken ( ) ;
63766373 }
63776374 loop: while ( true ) {
6378- switch ( t ) {
6375+ switch ( token ( ) ) {
63796376 case SyntaxKind . AtToken :
63806377 if ( state === JSDocState . BeginningOfLine || state === JSDocState . SawAsterisk ) {
63816378 removeTrailingNewlines ( comments ) ;
@@ -6435,12 +6432,11 @@ namespace ts {
64356432 pushComment ( scanner . getTokenText ( ) ) ;
64366433 break ;
64376434 }
6438- t = nextJSDocToken ( ) ;
6435+ nextJSDocToken ( ) ;
64396436 }
64406437 removeLeadingNewlines ( comments ) ;
64416438 removeTrailingNewlines ( comments ) ;
64426439 result = createJSDocComment ( ) ;
6443-
64446440 } ) ;
64456441
64466442 return result ;
@@ -6877,8 +6873,7 @@ namespace ts {
68776873 jsdocSignature . parameters = append ( jsdocSignature . parameters as MutableNodeArray < JSDocParameterTag > , child ) ;
68786874 }
68796875 const returnTag = tryParse ( ( ) => {
6880- if ( token ( ) === SyntaxKind . AtToken ) {
6881- nextJSDocToken ( ) ;
6876+ if ( parseOptionalJsdoc ( SyntaxKind . AtToken ) ) {
68826877 const tag = parseTag ( indent ) ;
68836878 if ( tag && tag . kind === SyntaxKind . JSDocReturnTag ) {
68846879 return tag as JSDocReturnTag ;
@@ -6997,12 +6992,12 @@ namespace ts {
69976992 let constraint : JSDocTypeExpression | undefined ;
69986993 if ( token ( ) === SyntaxKind . OpenBraceToken ) {
69996994 constraint = parseJSDocTypeExpression ( ) ;
7000- skipWhitespace ( ) ;
70016995 }
70026996
70036997 const typeParameters = [ ] ;
70046998 const typeParametersPos = getNodePos ( ) ;
7005- while ( true ) {
6999+ do {
7000+ skipWhitespace ( ) ;
70067001 const typeParameter = < TypeParameterDeclaration > createNode ( SyntaxKind . TypeParameter ) ;
70077002 if ( ! tokenIsIdentifierOrKeyword ( token ( ) ) ) {
70087003 parseErrorAtCurrentToken ( Diagnostics . Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces ) ;
@@ -7012,15 +7007,7 @@ namespace ts {
70127007 skipWhitespace ( ) ;
70137008 finishNode ( typeParameter ) ;
70147009 typeParameters . push ( typeParameter ) ;
7015- if ( token ( ) === SyntaxKind . CommaToken ) {
7016- // need to look for more type parameters
7017- nextJSDocToken ( ) ;
7018- skipWhitespace ( ) ;
7019- }
7020- else {
7021- break ;
7022- }
7023- }
7010+ } while ( parseOptionalJsdoc ( SyntaxKind . CommaToken ) ) ;
70247011
70257012 if ( constraint ) {
70267013 first ( typeParameters ) . constraint = constraint . type ;
@@ -7038,6 +7025,14 @@ namespace ts {
70387025 return currentToken = scanner . scanJSDocToken ( ) ;
70397026 }
70407027
7028+ function parseOptionalJsdoc ( t : JsDocSyntaxKind ) : boolean {
7029+ if ( token ( ) === t ) {
7030+ nextJSDocToken ( ) ;
7031+ return true ;
7032+ }
7033+ return false ;
7034+ }
7035+
70417036 function parseJSDocEntityName ( ) : EntityName {
70427037 let entity : EntityName = parseJSDocIdentifierName ( /*createIfMissing*/ true ) ;
70437038 if ( parseOptional ( SyntaxKind . OpenBracketToken ) ) {
0 commit comments