@@ -250,14 +250,28 @@ export class ApiModelGenerator {
250
250
break ;
251
251
252
252
case ts . SyntaxKind . VariableDeclaration :
253
- this . _processApiVariable ( astDeclaration , context ) ;
253
+ // check for arrow functions in variable declaration
254
+ const functionDeclaration : ts . FunctionDeclaration | undefined =
255
+ this . _hasFunctionDeclaration ( astDeclaration ) ;
256
+ if ( functionDeclaration ) {
257
+ this . _processApiFunction ( astDeclaration , context , functionDeclaration ) ;
258
+ } else {
259
+ this . _processApiVariable ( astDeclaration , context ) ;
260
+ }
254
261
break ;
255
262
256
263
default :
257
264
// ignore unknown types
258
265
}
259
266
}
260
267
268
+ private _hasFunctionDeclaration ( astDeclaration : AstDeclaration ) : ts . FunctionDeclaration | undefined {
269
+ const children : ts . Node [ ] = astDeclaration . declaration . getChildren (
270
+ astDeclaration . declaration . getSourceFile ( )
271
+ ) ;
272
+ return children . find ( ts . isFunctionTypeNode ) as ts . FunctionDeclaration | undefined ;
273
+ }
274
+
261
275
private _processChildDeclarations ( astDeclaration : AstDeclaration , context : IProcessAstEntityContext ) : void {
262
276
for ( const childDeclaration of astDeclaration . children ) {
263
277
this . _processDeclaration ( childDeclaration , {
@@ -544,7 +558,11 @@ export class ApiModelGenerator {
544
558
}
545
559
}
546
560
547
- private _processApiFunction ( astDeclaration : AstDeclaration , context : IProcessAstEntityContext ) : void {
561
+ private _processApiFunction (
562
+ astDeclaration : AstDeclaration ,
563
+ context : IProcessAstEntityContext ,
564
+ altFunctionDeclaration ?: ts . FunctionDeclaration
565
+ ) : void {
548
566
const { name, isExported, parentApiItem } = context ;
549
567
550
568
const overloadIndex : number = this . _collector . getOverloadIndex ( astDeclaration ) ;
@@ -554,7 +572,7 @@ export class ApiModelGenerator {
554
572
555
573
if ( apiFunction === undefined ) {
556
574
const functionDeclaration : ts . FunctionDeclaration =
557
- astDeclaration . declaration as ts . FunctionDeclaration ;
575
+ altFunctionDeclaration ?? ( astDeclaration . declaration as ts . FunctionDeclaration ) ;
558
576
559
577
const nodesToCapture : IExcerptBuilderNodeToCapture [ ] = [ ] ;
560
578
0 commit comments