不确定JSdocs时该如何放置@return

问题描述 投票:1回答:1

你好,我有一个函数,该函数返回该函数内部的函数结果。因此,我不确定要在@return中添加什么。我正在学习JSdocs,这是我偶然发现的一个问题。

这里是代码:

/**
 * @param           {string} id
 * @param           {Array} data
 * @returns         ??
 * @description     Takes in an ID to find the processor it needs and the data it needs to pass to the processor.
 */

processData(id, data) {
    let res = Object.values(methods).find(entry => entry.id === id).dataProcessor;
    if (res !== undefined) return res(data);
    console.error(`There is no method that belongs to id:${id}`)
}

由于它返回res.data(data)的结果,您将在文档中的@return中放入什么。

javascript jsdoc
1个回答
1
投票

在这种情况下,通常返回{Object}或ALL {*}甚至ANY {?}。>

https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System

© www.soinside.com 2019 - 2024. All rights reserved.