小编HaS*_*Ste的帖子

JSDoc-如何用通用键名记录对象?

我需要用JSDoc记录一个ES6类,该类接收一个对象,该对象的属性将键名用作人员名称,因此键名几乎可以是任何字符串,而无需预定义。因此,对象的结构应如下所示:

{
    "Name of person": {
        "age": 31,
        "hobby": "Tennis"
    },
    "Name of another person": {
        "age": 29,
        "hobby": "Running"
    }
}
Run Code Online (Sandbox Code Playgroud)

因此,每个人的名字都是关键,但可以是任何东西,不是预先定义的。我要记录的示例:

class ExampleClass {
    /**
     * Creates an instance of ExampleClass
     * @param {Object} peopleObj            - Contains information about people.
     * @param {String} peopleObj.name       - The name of the person. <----- how should this be documented?
     * @param {Number} peopleObj.name.age   - The age of the person.
     * @param {String} peopleObj.name.hobby - The hobby of the person.
     * @memberof …
Run Code Online (Sandbox Code Playgroud)

javascript documentation jsdoc ecmascript-6

5
推荐指数
1
解决办法
2111
查看次数

标签 统计

documentation ×1

ecmascript-6 ×1

javascript ×1

jsdoc ×1