简体   繁体   English

JSDoc在一个对象的属性上描述一个函数的params

[英]JSDoc on an object's properties to describe params of a function

If I have an object (or more precisely an object assigned to module.exports in node) and this object's properties may consist of functions, how do I document the parameters and return value of the function? 如果我有一个对象(或者更确切地说是一个分配给module.exports的对象),并且该对象的属性可能包含函数,那么如何记录函数的参数和返回值?

Example: 例:

module.exports = {
    /**
     * Adds two numbers together.
     * @param {number} first The first number
     * @param {number} second The second number
     * @return {number} The sum of the two numbers
    */
    "add": function(first, second) {
        return first + second;
    }
}

This doesn't seem to be supported (at least not in VSCode) and I couldn't find anywhere in JSDoc docs that describe a way to document the arguments of the function in this scenario (or just for a plain object). 这似乎不受支持(至少在VSCode中没有),我在JSDoc文档中找不到任何描述在这种情况下(或仅仅是普通对象)记录函数参数的方法。 The JSDoc description works (it is displayed by VSCode's Intellisense), but the param definitions and return definition is not. JSDoc描述有效(它由VSCode的Intellisense显示),但参数定义和返回定义不是。

Is there a way to document functions so they show up in objects that reference them? 有没有办法记录函数,以便它们显示在引用它们的对象中?

This actually works correctly in VSCode. 这实际上在VSCode中正常工作。 My problem was that my @param types didn't have proper capitalization ( Object works while object does not) which means Intellisense won't work. 我的问题是,我的@param类型没有适当的资本化( Object的作品,而object没有),这意味着智能感知将无法正常工作。 Note: Number and number are both fine, and I suspect there are other "types" that also don't care about case sensitivity. 注意: Numbernumber都很好,我怀疑还有其他“类型”也不关心区分大小写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM