@@ -481,12 +481,12 @@ namespace ts {
481
481
return visitNodes ( cbNode , cbNodes , ( node as JSDocFunctionType ) . parameters ) ||
482
482
visitNode ( cbNode , ( node as JSDocFunctionType ) . type ) ;
483
483
case SyntaxKind . JSDocComment :
484
- return ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocText | JSDocLink > | undefined ) )
484
+ return ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocComment > | undefined ) )
485
485
|| visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . tags ) ;
486
486
case SyntaxKind . JSDocSeeTag :
487
487
return visitNode ( cbNode , ( node as JSDocSeeTag ) . tagName ) ||
488
488
visitNode ( cbNode , ( node as JSDocSeeTag ) . name ) ||
489
- ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocText | JSDocLink > | undefined ) ) ;
489
+ ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocComment > | undefined ) ) ;
490
490
case SyntaxKind . JSDocNameReference :
491
491
return visitNode ( cbNode , ( node as JSDocNameReference ) . name ) ;
492
492
case SyntaxKind . JSDocMemberName :
@@ -498,54 +498,56 @@ namespace ts {
498
498
( ( node as JSDocPropertyLikeTag ) . isNameFirst
499
499
? visitNode ( cbNode , ( node as JSDocPropertyLikeTag ) . name ) ||
500
500
visitNode ( cbNode , ( node as JSDocPropertyLikeTag ) . typeExpression ) ||
501
- ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocText | JSDocLink > | undefined ) )
501
+ ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocComment > | undefined ) )
502
502
: visitNode ( cbNode , ( node as JSDocPropertyLikeTag ) . typeExpression ) ||
503
503
visitNode ( cbNode , ( node as JSDocPropertyLikeTag ) . name ) ) ||
504
- ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocText | JSDocLink > | undefined ) ) ;
504
+ ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocComment > | undefined ) ) ;
505
505
case SyntaxKind . JSDocAuthorTag :
506
506
return visitNode ( cbNode , ( node as JSDocTag ) . tagName ) ||
507
- ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocText | JSDocLink > | undefined ) ) ;
507
+ ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocComment > | undefined ) ) ;
508
508
case SyntaxKind . JSDocImplementsTag :
509
509
return visitNode ( cbNode , ( node as JSDocTag ) . tagName ) ||
510
510
visitNode ( cbNode , ( node as JSDocImplementsTag ) . class ) ||
511
- ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocText | JSDocLink > | undefined ) ) ;
511
+ ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocComment > | undefined ) ) ;
512
512
case SyntaxKind . JSDocAugmentsTag :
513
513
return visitNode ( cbNode , ( node as JSDocTag ) . tagName ) ||
514
514
visitNode ( cbNode , ( node as JSDocAugmentsTag ) . class ) ||
515
- ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocText | JSDocLink > | undefined ) ) ;
515
+ ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocComment > | undefined ) ) ;
516
516
case SyntaxKind . JSDocTemplateTag :
517
517
return visitNode ( cbNode , ( node as JSDocTag ) . tagName ) ||
518
518
visitNode ( cbNode , ( node as JSDocTemplateTag ) . constraint ) ||
519
519
visitNodes ( cbNode , cbNodes , ( node as JSDocTemplateTag ) . typeParameters ) ||
520
- ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocText | JSDocLink > | undefined ) ) ;
520
+ ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocComment > | undefined ) ) ;
521
521
case SyntaxKind . JSDocTypedefTag :
522
522
return visitNode ( cbNode , ( node as JSDocTag ) . tagName ) ||
523
523
( ( node as JSDocTypedefTag ) . typeExpression &&
524
524
( node as JSDocTypedefTag ) . typeExpression ! . kind === SyntaxKind . JSDocTypeExpression
525
525
? visitNode ( cbNode , ( node as JSDocTypedefTag ) . typeExpression ) ||
526
526
visitNode ( cbNode , ( node as JSDocTypedefTag ) . fullName ) ||
527
- ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocText | JSDocLink > | undefined ) )
527
+ ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocComment > | undefined ) )
528
528
: visitNode ( cbNode , ( node as JSDocTypedefTag ) . fullName ) ||
529
529
visitNode ( cbNode , ( node as JSDocTypedefTag ) . typeExpression ) ) ||
530
- ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocText | JSDocLink > | undefined ) ) ;
530
+ ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocComment > | undefined ) ) ;
531
531
case SyntaxKind . JSDocCallbackTag :
532
532
return visitNode ( cbNode , ( node as JSDocTag ) . tagName ) ||
533
533
visitNode ( cbNode , ( node as JSDocCallbackTag ) . fullName ) ||
534
534
visitNode ( cbNode , ( node as JSDocCallbackTag ) . typeExpression ) ||
535
- ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocText | JSDocLink > | undefined ) ) ;
535
+ ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocComment > | undefined ) ) ;
536
536
case SyntaxKind . JSDocReturnTag :
537
537
case SyntaxKind . JSDocTypeTag :
538
538
case SyntaxKind . JSDocThisTag :
539
539
case SyntaxKind . JSDocEnumTag :
540
540
return visitNode ( cbNode , ( node as JSDocTag ) . tagName ) ||
541
541
visitNode ( cbNode , ( node as JSDocReturnTag | JSDocTypeTag | JSDocThisTag | JSDocEnumTag ) . typeExpression ) ||
542
- ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocText | JSDocLink > | undefined ) ) ;
542
+ ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocComment > | undefined ) ) ;
543
543
case SyntaxKind . JSDocSignature :
544
544
return forEach ( ( node as JSDocSignature ) . typeParameters , cbNode ) ||
545
545
forEach ( ( node as JSDocSignature ) . parameters , cbNode ) ||
546
546
visitNode ( cbNode , ( node as JSDocSignature ) . type ) ;
547
547
case SyntaxKind . JSDocLink :
548
- return visitNode ( cbNode , ( node as JSDocLink ) . name ) ;
548
+ case SyntaxKind . JSDocLinkCode :
549
+ case SyntaxKind . JSDocLinkPlain :
550
+ return visitNode ( cbNode , ( node as JSDocLink | JSDocLinkCode | JSDocLinkPlain ) . name ) ;
549
551
case SyntaxKind . JSDocTypeLiteral :
550
552
return forEach ( ( node as JSDocTypeLiteral ) . jsDocPropertyTags , cbNode ) ;
551
553
case SyntaxKind . JSDocTag :
@@ -556,7 +558,7 @@ namespace ts {
556
558
case SyntaxKind . JSDocReadonlyTag :
557
559
case SyntaxKind . JSDocDeprecatedTag :
558
560
return visitNode ( cbNode , ( node as JSDocTag ) . tagName )
559
- || ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocText | JSDocLink > | undefined ) ) ;
561
+ || ( typeof ( node as JSDoc ) . comment === "string" ? undefined : visitNodes ( cbNode , cbNodes , ( node as JSDoc ) . comment as NodeArray < JSDocComment > | undefined ) ) ;
560
562
case SyntaxKind . PartiallyEmittedExpression :
561
563
return visitNode ( cbNode , ( node as PartiallyEmittedExpression ) . expression ) ;
562
564
}
@@ -7425,7 +7427,7 @@ namespace ts {
7425
7427
let linkEnd : number ;
7426
7428
let commentsPos : number | undefined ;
7427
7429
let comments : string [ ] = [ ] ;
7428
- const parts : ( JSDocLink | JSDocText ) [ ] = [ ] ;
7430
+ const parts : JSDocComment [ ] = [ ] ;
7429
7431
7430
7432
// + 3 for leading /**, - 5 in total for /** */
7431
7433
return scanner . scanRange ( start + 3 , length - 5 , ( ) => {
@@ -7681,10 +7683,10 @@ namespace ts {
7681
7683
return parseTagComments ( margin , indentText . slice ( margin ) ) ;
7682
7684
}
7683
7685
7684
- function parseTagComments ( indent : number , initialMargin ?: string ) : string | NodeArray < JSDocText | JSDocLink > | undefined {
7686
+ function parseTagComments ( indent : number , initialMargin ?: string ) : string | NodeArray < JSDocComment > | undefined {
7685
7687
const commentsPos = getNodePos ( ) ;
7686
7688
let comments : string [ ] = [ ] ;
7687
- const parts : ( JSDocLink | JSDocText ) [ ] = [ ] ;
7689
+ const parts : JSDocComment [ ] = [ ] ;
7688
7690
let linkEnd ;
7689
7691
let state = JSDocState . BeginningOfLine ;
7690
7692
let previousWhitespace = true ;
@@ -7800,7 +7802,8 @@ namespace ts {
7800
7802
}
7801
7803
7802
7804
function parseJSDocLink ( start : number ) {
7803
- if ( ! tryParse ( parseJSDocLinkPrefix ) ) {
7805
+ const linkType = tryParse ( parseJSDocLinkPrefix ) ;
7806
+ if ( ! linkType ) {
7804
7807
return undefined ;
7805
7808
}
7806
7809
nextTokenJSDoc ( ) ; // start at token after link, then skip any whitespace
@@ -7822,15 +7825,22 @@ namespace ts {
7822
7825
text . push ( scanner . getTokenText ( ) ) ;
7823
7826
nextTokenJSDoc ( ) ;
7824
7827
}
7825
- return finishNode ( factory . createJSDocLink ( name , text . join ( "" ) ) , start , scanner . getTextPos ( ) ) ;
7828
+ const create = linkType === "link" ? factory . createJSDocLink
7829
+ : linkType === "linkcode" ? factory . createJSDocLinkCode
7830
+ : factory . createJSDocLinkPlain ;
7831
+ return finishNode ( create ( name , text . join ( "" ) ) , start , scanner . getTextPos ( ) ) ;
7826
7832
}
7827
7833
7828
7834
function parseJSDocLinkPrefix ( ) {
7829
7835
skipWhitespaceOrAsterisk ( ) ;
7830
- return token ( ) === SyntaxKind . OpenBraceToken
7836
+ if ( token ( ) === SyntaxKind . OpenBraceToken
7831
7837
&& nextTokenJSDoc ( ) === SyntaxKind . AtToken
7832
- && tokenIsIdentifierOrKeyword ( nextTokenJSDoc ( ) )
7833
- && scanner . getTokenValue ( ) === "link" ;
7838
+ && tokenIsIdentifierOrKeyword ( nextTokenJSDoc ( ) ) ) {
7839
+ const kind = scanner . getTokenValue ( ) ;
7840
+ if ( kind === "link" || kind === "linkcode" || kind === "linkplain" ) {
7841
+ return kind ;
7842
+ }
7843
+ }
7834
7844
}
7835
7845
7836
7846
function parseUnknownTag ( start : number , tagName : Identifier , indent : number , indentText : string ) {
@@ -7969,7 +7979,7 @@ namespace ts {
7969
7979
commentEnd = scanner . getStartPos ( ) ;
7970
7980
}
7971
7981
const allParts = typeof comments !== "string"
7972
- ? createNodeArray ( concatenate ( [ finishNode ( textOnly , commentStart , commentEnd ) ] , comments ) as ( JSDocText | JSDocLink ) [ ] , commentStart ) // cast away readonly
7982
+ ? createNodeArray ( concatenate ( [ finishNode ( textOnly , commentStart , commentEnd ) ] , comments ) as JSDocComment [ ] , commentStart ) // cast away readonly
7973
7983
: textOnly . text + comments ;
7974
7984
return finishNode ( factory . createJSDocAuthorTag ( tagName , allParts ) , start ) ;
7975
7985
}
@@ -8030,7 +8040,7 @@ namespace ts {
8030
8040
return node ;
8031
8041
}
8032
8042
8033
- function parseSimpleTag ( start : number , createTag : ( tagName : Identifier | undefined , comment ?: string | NodeArray < JSDocText | JSDocLink > ) => JSDocTag , tagName : Identifier , margin : number , indentText : string ) : JSDocTag {
8043
+ function parseSimpleTag ( start : number , createTag : ( tagName : Identifier | undefined , comment ?: string | NodeArray < JSDocComment > ) => JSDocTag , tagName : Identifier , margin : number , indentText : string ) : JSDocTag {
8034
8044
return finishNode ( createTag ( tagName , parseTrailingTagComments ( start , getNodePos ( ) , margin , indentText ) ) , start ) ;
8035
8045
}
8036
8046
0 commit comments