@@ -6268,7 +6268,6 @@ namespace ts {
6268
6268
scanner . scanRange ( start + 3 , length - 5 , ( ) => {
6269
6269
// Initially we can parse out a tag. We also have seen a starting asterisk.
6270
6270
// This is so that /** * @type */ doesn't parse.
6271
- let advanceToken = true ;
6272
6271
let state = JSDocState . SawAsterisk ;
6273
6272
let margin : number | undefined = undefined ;
6274
6273
// + 4 for leading '/** '
@@ -6300,7 +6299,6 @@ namespace ts {
6300
6299
// Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning
6301
6300
// for malformed examples like `/** @param {string } x @returns {number } the length */`
6302
6301
state = JSDocState . BeginningOfLine ;
6303
- advanceToken = false ;
6304
6302
margin = undefined ;
6305
6303
indent ++ ;
6306
6304
}
@@ -6352,13 +6350,7 @@ namespace ts {
6352
6350
pushComment ( scanner . getTokenText ( ) ) ;
6353
6351
break ;
6354
6352
}
6355
- if ( advanceToken ) {
6356
- t = nextJSDocToken ( ) ;
6357
- }
6358
- else {
6359
- advanceToken = true ;
6360
- t = currentToken as JsDocSyntaxKind ;
6361
- }
6353
+ t = nextJSDocToken ( ) ;
6362
6354
}
6363
6355
removeLeadingNewlines ( comments ) ;
6364
6356
removeTrailingNewlines ( comments ) ;
@@ -6458,7 +6450,7 @@ namespace ts {
6458
6450
addTag ( tag ) ;
6459
6451
}
6460
6452
6461
- function parseTagComments ( indent : number ) : string {
6453
+ function parseTagComments ( indent : number ) : string | undefined {
6462
6454
const comments : string [ ] = [ ] ;
6463
6455
let state = JSDocState . BeginningOfLine ;
6464
6456
let margin : number | undefined ;
@@ -6480,6 +6472,8 @@ namespace ts {
6480
6472
indent = 0 ;
6481
6473
break ;
6482
6474
case SyntaxKind . AtToken :
6475
+ scanner . setTextPos ( scanner . getTextPos ( ) - 1 ) ;
6476
+ // falls through
6483
6477
case SyntaxKind . EndOfFileToken :
6484
6478
// Done
6485
6479
break loop;
@@ -6515,7 +6509,7 @@ namespace ts {
6515
6509
6516
6510
removeLeadingNewlines ( comments ) ;
6517
6511
removeTrailingNewlines ( comments ) ;
6518
- return comments . join ( "" ) ;
6512
+ return comments . length === 0 ? undefined : comments . join ( "" ) ;
6519
6513
}
6520
6514
6521
6515
function parseUnknownTag ( atToken : AtToken , tagName : Identifier ) {
@@ -6607,10 +6601,7 @@ namespace ts {
6607
6601
const start = scanner . getStartPos ( ) ;
6608
6602
let children : JSDocParameterTag [ ] ;
6609
6603
while ( child = tryParse ( ( ) => parseChildParameterOrPropertyTag ( PropertyLikeParse . Parameter , name ) ) ) {
6610
- if ( ! children ) {
6611
- children = [ ] ;
6612
- }
6613
- children . push ( child ) ;
6604
+ children = append ( children , child ) ;
6614
6605
}
6615
6606
if ( children ) {
6616
6607
jsdocTypeLiteral = < JSDocTypeLiteral > createNode ( SyntaxKind . JSDocTypeLiteral , start ) ;
@@ -6727,10 +6718,7 @@ namespace ts {
6727
6718
}
6728
6719
}
6729
6720
else {
6730
- if ( ! jsdocTypeLiteral . jsDocPropertyTags ) {
6731
- jsdocTypeLiteral . jsDocPropertyTags = [ ] as MutableNodeArray < JSDocPropertyTag > ;
6732
- }
6733
- ( jsdocTypeLiteral . jsDocPropertyTags as MutableNodeArray < JSDocPropertyTag > ) . push ( child ) ;
6721
+ jsdocTypeLiteral . jsDocPropertyTags = append ( jsdocTypeLiteral . jsDocPropertyTags as MutableNodeArray < JSDocPropertyTag > , child ) ;
6734
6722
}
6735
6723
}
6736
6724
if ( jsdocTypeLiteral ) {
0 commit comments