代码之家  ›  专栏  ›  技术社区  ›  Pulasthi Bandara

如何使用JsDoc记录解构参数

  •  16
  • Pulasthi Bandara  · 技术社区  · 7 年前

    如何记录在函数参数中解构的函数参数?

    /**
     * Function deconstructs argument and do stuff.
     * @param {} *** what should i do here? ***
     */
    function someFunction({ key1, key2, key3 }) {
        // do function stuffs
    }
    
    1 回复  |  直到 7 年前
        1
  •  27
  •   Felix Kling    7 年前

    @param wiki page :

    如果参数在没有显式名称的情况下被分解,则可以为对象指定适当的名称并记录其属性。

    /**
     * Assign the project to an employee.
     * @param {Object} employee - The employee who is responsible for the project.
     * @param {string} employee.name - The name of the employee.
     * @param {string} employee.department - The employee's department.
     */
    Project.prototype.assign = function({ name, department }) {
        // ...
    };