我想要一个很好的文档,这就是为什么我要写:
@param {(device)} device
当我单击参数设备时,我想看到类似以下内容的东西:
configInSync:null
lastUpgradeStatus:"none"
lastUpgradeStatusReported:true
modelID:"F4FE7EBE"
packages:Object {}
registrationInSync:false
softwareVersion:3
UUID:"85196BFA6E90"
所以我想定义自己的类型,可以吗?当然我在尝试
@typedef
但是如何创建这样的“设备”类型呢?我尝试过:
@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
*/
答案 0 :(得分:0)
您可以使用typedef
@typedef标记对于记录自定义类型很有用,特别是如果您希望重复引用它们。然后,这些类型可以在其他需要类型的标记中使用,例如@type或@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.
*/