File tree 1 file changed +8
-5
lines changed
packages/react-docgen/src/handlers
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -5,18 +5,21 @@ import resolveToValue from '../utils/resolveToValue.js';
5
5
import type { NodePath } from '@babel/traverse' ;
6
6
import type { ComponentNode } from '../resolver/index.js' ;
7
7
import type { Handler } from './index.js' ;
8
+ import type { Decorator } from '@babel/types' ;
8
9
9
10
function getDocblockFromComponent ( path : NodePath ) : string | null {
10
11
let description : string | null = null ;
11
12
12
13
if ( path . isClassDeclaration ( ) || path . isClassExpression ( ) ) {
14
+ const decorators = path . get ( 'decorators' ) as
15
+ | Array < NodePath < Decorator > >
16
+ | null
17
+ | undefined ;
18
+
13
19
// If we have a class declaration or expression, then the comment might be
14
20
// attached to the last decorator instead as trailing comment.
15
- if ( path . node . decorators && path . node . decorators . length > 0 ) {
16
- description = getDocblock (
17
- path . get ( 'decorators' ) [ path . node . decorators . length - 1 ] ,
18
- true ,
19
- ) ;
21
+ if ( decorators && decorators . length > 0 ) {
22
+ description = getDocblock ( decorators [ decorators . length - 1 ] ! , true ) ;
20
23
}
21
24
}
22
25
if ( description == null ) {
You can’t perform that action at this time.
0 commit comments