File tree Expand file tree Collapse file tree
packages/react-docgen/src/handlers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,18 +5,21 @@ import resolveToValue from '../utils/resolveToValue.js';
55import type { NodePath } from '@babel/traverse' ;
66import type { ComponentNode } from '../resolver/index.js' ;
77import type { Handler } from './index.js' ;
8+ import type { Decorator } from '@babel/types' ;
89
910function getDocblockFromComponent ( path : NodePath ) : string | null {
1011 let description : string | null = null ;
1112
1213 if ( path . isClassDeclaration ( ) || path . isClassExpression ( ) ) {
14+ const decorators = path . get ( 'decorators' ) as
15+ | Array < NodePath < Decorator > >
16+ | null
17+ | undefined ;
18+
1319 // If we have a class declaration or expression, then the comment might be
1420 // 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 ) ;
2023 }
2124 }
2225 if ( description == null ) {
You can’t perform that action at this time.
0 commit comments