【问题标题】:how to document curried functions with Js docs如何使用 Js 文档记录 curried 函数
【发布时间】:2020-10-19 21:54:12
【问题描述】:

我正在尝试使用 Js 文档来生成我的项目的静态文档,但是当我尝试运行 js doc 命令时出现很多解析错误,仅发生在我有 curried 函数的地方,我的代码正常工作,错误是仅在 js 文档上,它是一个 lib 错误还是我做错了什么?

/**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 }

错误:

【问题讨论】:

    标签: javascript jsdoc


    【解决方案1】:

    我不认为你可以从接收它的函数中记录返回函数的参数。你必须像这样拆分文档:

    /**
     * @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;
    

    【讨论】:

      猜你喜欢
      • 2021-11-07
      • 2017-05-10
      • 2018-05-04
      • 2015-04-23
      • 1970-01-01
      • 2021-12-11
      • 1970-01-01
      • 2019-09-21
      • 2013-05-30
      相关资源
      最近更新 更多