JSDocs:函数返回函数->如何正确声明返回的函数

时间:2019-07-08 06:25:15

标签: javascript function types typedef jsdoc

我正在尝试找出如何在JSDocs中正确声明返回的函数。这是我当前的代码。

/**
 * An assertation function.
 * @typedef {Function} Assertation
 * @param {boolean} condition - Condition of assertation
 * @param {string} source - Source of the error
 * @param {Object|string} msg - Message to show
 * @param {string} [method] - Method on which errorHandler was invoked
 */

/**
 * Creates an assertion by calling console[type].
 * @param {string} [type=info] - Type of assertation
 * @returns {Assertation}
 */
const createAssertation = (type = 'info') => (condition, source, msg, method) => {
  if (condition && process.env.NODE_ENV !== 'production') {
    console[type](createMessage(source, msg, method), msg);
  }
};

0 个答案:

没有答案