@@ -7,10 +7,11 @@ import type {
77 TypeNode ,
88 TSIndexSignature ,
99 TSTypeReference ,
10+ Parameter ,
1011} from '@typescript-eslint/types/dist/ts-estree' ;
1112import { AST_NODE_TYPES } from '@typescript-eslint/typescript-estree' ;
1213import type { ClassReferenceLoaded , InterfaceLoaded } from './ClassIndex' ;
13- import type { CommentData } from './CommentLoader' ;
14+ import type { CommentData , ConstructorCommentData } from './CommentLoader' ;
1415import { CommentLoader } from './CommentLoader' ;
1516import type { ConstructorData } from './ConstructorLoader' ;
1617import type { TypeReferenceOverride } from './typereferenceoverride/TypeReferenceOverride' ;
@@ -43,18 +44,34 @@ export class ParameterLoader {
4344 // Load all constructor parameters
4445 const parameters : ParameterDataField < ParameterRangeUnresolved > [ ] = [ ] ;
4546 for ( const field of constructor . value . params ) {
46- if ( field . type === AST_NODE_TYPES . Identifier ) {
47- const commentData = constructorCommentData [ field . name ] || { } ;
48- if ( ! commentData . ignored ) {
49- parameters . push ( this . loadField ( field , commentData ) ) ;
50- }
51- } else {
52- throw new Error ( `Could not understand constructor parameter type ${ field . type } in ${ this . classLoaded . localName } at ${ this . classLoaded . fileName } ` ) ;
53- }
47+ this . loadConstructorField ( parameters , constructorCommentData , field ) ;
5448 }
5549 return { parameters } ;
5650 }
5751
52+ /**
53+ * Load the parameter data from the given field in a constructor.
54+ * @param parameters The array of parameters that will be appended to.
55+ * @param constructorCommentData Comment data from the constructor.
56+ * @param field The field to load.
57+ */
58+ public loadConstructorField (
59+ parameters : ParameterDataField < ParameterRangeUnresolved > [ ] ,
60+ constructorCommentData : ConstructorCommentData ,
61+ field : Parameter ,
62+ ) : void {
63+ if ( field . type === AST_NODE_TYPES . Identifier ) {
64+ const commentData = constructorCommentData [ field . name ] || { } ;
65+ if ( ! commentData . ignored ) {
66+ parameters . push ( this . loadField ( field , commentData ) ) ;
67+ }
68+ } else if ( field . type === AST_NODE_TYPES . TSParameterProperty ) {
69+ this . loadConstructorField ( parameters , constructorCommentData , field . parameter ) ;
70+ } else {
71+ throw new Error ( `Could not understand constructor parameter type ${ field . type } in ${ this . classLoaded . localName } at ${ this . classLoaded . fileName } ` ) ;
72+ }
73+ }
74+
5875 /**
5976 * Load all parameter data from all fields in the given interface.
6077 * If methods are found in the interface, an error is thrown.
0 commit comments