在文档中创建自己的类型

Create own type in documentation

我想要一个很好的文档,这就是为什么我想写:

@param {(device)} device

当我点击参数设备时,我想看到如下内容:

configInSync:null
lastUpgradeStatus:"none"
lastUpgradeStatusReported:true
modelID:"F4FE7EBE"
packages:Object {}
registrationInSync:false
softwareVersion:3
UUID:"85196BFA6E90"

所以我想定义我自己的类型,可以吗?当然,我正在尝试

@typedef

但是如何创建这样的 "defice" 类型呢?我被试过:

@typedef {configInSync:null
lastUpgradeStatus:"none"
lastUpgradeStatusReported:true
modelID:"F4FE7EBE"
packages:Object {}
registrationInSync:false
softwareVersion:3
UUID:"85196BFA6E90"} device

解决方法:需要在类型中定义每一个属性,如:

/**
 * @typedef {object} MessageProperties
 * @property {string} replyTo
 * @property {string} type
 * @property {string} messageId
 * @property {string} contentType
 * @property {string} correlationId
 * @property {number} expiration
 * @property {object} headers
 */

您可以使用typedef

The @typedef tag is useful for documenting custom types, particularly if you wish to refer to them repeatedly. These types can then be used within other tags expecting a type, such as @type or @param.

/**
 * The complete Triforce, or one or more components of the Triforce.
 * @typedef {Object} WishGranter~Triforce
 * @property {boolean} hasCourage - Indicates whether the Courage component is present.
 * @property {boolean} hasPower - Indicates whether the Power component is present.
 * @property {boolean} hasWisdom - Indicates whether the Wisdom component is present.
 */