tsdoc
tsdoc copied to clipboard
Document inline parameters
Hello,
I would like to know if there is currently a defined way to document such a function:
function error(message: string, mOptions?: { onClose?: () => void, title?: string})
I tried for example this approach:
/**
* Error !
* @param {string} message - a message
* @param {any=} mOptions - some options
* @param {any=} mOptions.onClose - a callback function
* @param {string=} mOptions.title - a title, as string
* @returns {void}
*/
Of course in "pure" TypeScript an interface would be created and documented. That would be the way to go. But here The function exists and already has such a signature. I only need to add some documentation to help using it.
Do you know if I am filling a feature request here, or if this is already supported by tsdoc ? I can't find it :(
Thanks !
@GuillaumedesPommareSAP I think it would be reasonable for TSDoc to allow a .
in the parameter name, like this:
/**
* @param message - a message
* @param mOptions - some options
* @param mOptions.onClose - a callback function
* @param mOptions.title - a title, as string
* @returns the result
*/
I'm not sure we'd want to get involved with type annotations, since the grammar for that will be complicated (especially in TypeScript source code). In your example, that information is already captured by the type annotation anyway.
Does that make sense?
Hello @octogonz !
Sure ! My bad ! My question was focusing on the dot notation, and I kept the type information which is not useful here. The function itself is already typed.
I had in mind a dot notation like in jsdoc for the parameters with properties. So your example would be the target, in my case.