@@ -6365,17 +6365,14 @@ namespace ts {
6365
6365
indent += text . length ;
6366
6366
}
6367
6367
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 ) ) {
6373
6371
state = JSDocState . BeginningOfLine ;
6374
6372
indent = 0 ;
6375
- t = nextJSDocToken ( ) ;
6376
6373
}
6377
6374
loop: while ( true ) {
6378
- switch ( t ) {
6375
+ switch ( token ( ) ) {
6379
6376
case SyntaxKind . AtToken :
6380
6377
if ( state === JSDocState . BeginningOfLine || state === JSDocState . SawAsterisk ) {
6381
6378
removeTrailingNewlines ( comments ) ;
@@ -6435,12 +6432,11 @@ namespace ts {
6435
6432
pushComment ( scanner . getTokenText ( ) ) ;
6436
6433
break ;
6437
6434
}
6438
- t = nextJSDocToken ( ) ;
6435
+ nextJSDocToken ( ) ;
6439
6436
}
6440
6437
removeLeadingNewlines ( comments ) ;
6441
6438
removeTrailingNewlines ( comments ) ;
6442
6439
result = createJSDocComment ( ) ;
6443
-
6444
6440
} ) ;
6445
6441
6446
6442
return result ;
@@ -6877,8 +6873,7 @@ namespace ts {
6877
6873
jsdocSignature . parameters = append ( jsdocSignature . parameters as MutableNodeArray < JSDocParameterTag > , child ) ;
6878
6874
}
6879
6875
const returnTag = tryParse ( ( ) => {
6880
- if ( token ( ) === SyntaxKind . AtToken ) {
6881
- nextJSDocToken ( ) ;
6876
+ if ( parseOptionalJsdoc ( SyntaxKind . AtToken ) ) {
6882
6877
const tag = parseTag ( indent ) ;
6883
6878
if ( tag && tag . kind === SyntaxKind . JSDocReturnTag ) {
6884
6879
return tag as JSDocReturnTag ;
@@ -6997,12 +6992,12 @@ namespace ts {
6997
6992
let constraint : JSDocTypeExpression | undefined ;
6998
6993
if ( token ( ) === SyntaxKind . OpenBraceToken ) {
6999
6994
constraint = parseJSDocTypeExpression ( ) ;
7000
- skipWhitespace ( ) ;
7001
6995
}
7002
6996
7003
6997
const typeParameters = [ ] ;
7004
6998
const typeParametersPos = getNodePos ( ) ;
7005
- while ( true ) {
6999
+ do {
7000
+ skipWhitespace ( ) ;
7006
7001
const typeParameter = < TypeParameterDeclaration > createNode ( SyntaxKind . TypeParameter ) ;
7007
7002
if ( ! tokenIsIdentifierOrKeyword ( token ( ) ) ) {
7008
7003
parseErrorAtCurrentToken ( Diagnostics . Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces ) ;
@@ -7012,15 +7007,7 @@ namespace ts {
7012
7007
skipWhitespace ( ) ;
7013
7008
finishNode ( typeParameter ) ;
7014
7009
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 ) ) ;
7024
7011
7025
7012
if ( constraint ) {
7026
7013
first ( typeParameters ) . constraint = constraint . type ;
@@ -7038,6 +7025,14 @@ namespace ts {
7038
7025
return currentToken = scanner . scanJSDocToken ( ) ;
7039
7026
}
7040
7027
7028
+ function parseOptionalJsdoc ( t : JsDocSyntaxKind ) : boolean {
7029
+ if ( token ( ) === t ) {
7030
+ nextJSDocToken ( ) ;
7031
+ return true ;
7032
+ }
7033
+ return false ;
7034
+ }
7035
+
7041
7036
function parseJSDocEntityName ( ) : EntityName {
7042
7037
let entity : EntityName = parseJSDocIdentifierName ( /*createIfMissing*/ true ) ;
7043
7038
if ( parseOptional ( SyntaxKind . OpenBracketToken ) ) {
0 commit comments