JSDocs: функция возвращает функцию -> Как правильно объявить возвращаемую функцию - PullRequest
2 голосов
/ 08 июля 2019

Я пытаюсь выяснить, как правильно объявить возвращаемую функцию в 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);
  }
};
...