How to document a callback function parameter in typescript

550 Views Asked by At

I am using TypeDoc to generate documentation from my typescript files. Let say I have this source code

/**
 * Some function
 * @param bar some callback function
 */
export function foo(bar:(x:number)=>void)
{

}

Which gives me this output

generated documentation

I could have make an extra type for bar then document it

/**
 * @param x callback parameter
 */
export type Bar = (x:number)=>void

/**
 * Some function
 * @param bar some callback function
 */
 export function foo(bar:Bar)
 {
 
 }

which output

documentation of foo with Bar declared documentation of Bar

But it would look nicer if the documentation of a callback can be inlined. Is it possible to document x without declaring an extra type just for the callback?

0

There are 0 best solutions below