@@ -18,7 +18,7 @@ import {
18
18
} from "../factories/comment" ;
19
19
import { Converter } from "../converter" ;
20
20
import type { Context } from "../context" ;
21
- import { ReflectionType , SourceReference } from "../../models" ;
21
+ import { ReflectionType , SourceReference , TypeVisitor } from "../../models" ;
22
22
import {
23
23
BindOption ,
24
24
filterMap ,
@@ -455,21 +455,32 @@ export class CommentPlugin extends ConverterComponent {
455
455
456
456
// Moves tags like `@param foo.bar docs for bar` into the `bar` property of the `foo` parameter.
457
457
function moveNestedParamTags ( comment : Comment , parameter : ParameterReflection ) {
458
- if ( parameter . type instanceof ReflectionType ) {
459
- const tags = comment . tags . filter (
460
- ( t ) =>
461
- t . tagName === "param" &&
462
- t . paramName . startsWith ( `${ parameter . name } .` )
463
- ) ;
458
+ const visitor : Partial < TypeVisitor > = {
459
+ reflection ( target ) {
460
+ const tags = comment . tags . filter (
461
+ ( t ) =>
462
+ t . tagName === "param" &&
463
+ t . paramName . startsWith ( `${ parameter . name } .` )
464
+ ) ;
464
465
465
- for ( const tag of tags ) {
466
- const path = tag . paramName . split ( "." ) ;
467
- path . shift ( ) ;
468
- const child = parameter . type . declaration . getChildByName ( path ) ;
466
+ for ( const tag of tags ) {
467
+ const path = tag . paramName . split ( "." ) ;
468
+ path . shift ( ) ;
469
+ const child = target . declaration . getChildByName ( path ) ;
469
470
470
- if ( child && ! child . comment ) {
471
- child . comment = new Comment ( tag . text ) ;
471
+ if ( child && ! child . comment ) {
472
+ child . comment = new Comment ( tag . text ) ;
473
+ }
472
474
}
473
- }
474
- }
475
+ } ,
476
+ // #1876, also do this for unions/intersections.
477
+ union ( u ) {
478
+ u . types . forEach ( ( t ) => t . visit ( visitor ) ) ;
479
+ } ,
480
+ intersection ( i ) {
481
+ i . types . forEach ( ( t ) => t . visit ( visitor ) ) ;
482
+ } ,
483
+ } ;
484
+
485
+ parameter . type ?. visit ( visitor ) ;
475
486
}
0 commit comments