我用 JavaScript 编写了以下代码 (
.js
):
/**
* @typedef {Object} AccountType
* @property Regular - Users have username and password
* @property HotspotMAC - Users have user name only (it is the MAC address of the LAN / WLAN card). The Mikrotik Hotspot
* system will automatically log on Hotspot MAC users without requesting the user name and password.
* @property MikrotikACL - Is used to allow the connection for a specific WLAN CPE (Mikrotik AP)
* @property StarOSACL - Is used to allow the connection for a specific WLAN CPE using (StarOS AP)
* @property DOCSIS - Is used by DOCSIS cable modems
*/
/** @type {AccountType} */
const AccountType = {
Regular: 0,
HotspotMAC: 1,
MikrotikACL: 3,
StarOSACL: 4,
DOCSIS: 6,
}
将文件的文件扩展名更改为
.ts
,当我将鼠标悬停在此对象中的任何属性上时,会删除这些描述:
如何保留这些属性的描述并解决此问题?
当我在
.ts
文件中时,我是否默认使用 tsdoc 而不是 jsdoc?
根据实际情况撰写
/** ... */
评论 type
-
/** (Description of AccountType here) */
type AccountType = {
/** Users have username and password */
Regular: number
/** Users have user name only (it is the MAC address of the LAN / WLAN card). The Mikrotik Hotspot
* system will automatically log on Hotspot MAC users without requesting the user name and password. */
HotspotMAC: number
/** Is used to allow the connection for a specific WLAN CPE (Mikrotik AP) */
MikrotikACL: number
/** Is used to allow the connection for a specific WLAN CPE using (StarOS AP) */
StarOSACL: number
/** Is used by DOCSIS cable modems */
DOCSIS: number
}
定义对象时,将类型指定为
AccountType
-
const myAccount: AccountType = {
Regular: 0,
HotspotMAC: 1,
MikrotikACL: 3,
StarOSACL: 4,
DOCSIS: 6,
}
现在,当您将鼠标悬停在事物上时,您会看到提示 -