Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to document curried functions with Js docs

Im trying to use Js docs to generate a static documentation of my project but i got a lot of parse errors when i try to run the js doc command, occurs only where I have curried function, my code works normaly the error are only on js docs, its a lib error or did i do something wrong ?

/**Responsible for fetch the data that will be loaded in the graph within the dialog
 *
 * @param {function} dispatch redux dispatch function
 * @param {String} timeMode time mode used on metric page Example: 'Mensal'
 * @param {String} dialogType type of the dialog used to request de correct data and render the body Example: 'WARN_NETWORK_DRIVE'
 * @returns {(timeMode: String) => (dialogType: String) => Promise<void>}
 */
export const fetchGraphicData = dispatch => timeMode => async dialogType => {...function logic }

error: enter image description here

like image 945
Aryel Alves Avatar asked Sep 14 '25 17:09

Aryel Alves


1 Answers

I don't think you can document arguments for a returned function from the function that receives it.. you'd have to split out the documentation like:

/**
 * @param {String} dialogType type of the dialog used to request de correct data and render the body Example: 'WARN_NETWORK_DRIVE'
 */
const dialogFn = async dialogType => { };

/**
 * @param {String} timeMode time mode used on metric page Example: 'Mensal'
 */
const timeModeFn = timeMode => dialogFn;

/**
 * Responsible for fetch the data that will be loaded in the graph within the dialog
 *
 * @param {function} dispatch redux dispatch function
 * @returns {timeModeFn} timeModeFn
 */
export const fetchGraphicData = dispatch => timeModeFn;
like image 74
kavun Avatar answered Sep 16 '25 08:09

kavun