【发布时间】:2018-10-10 22:44:55
【问题描述】:
我正在尝试记录以下仅返回三个值的方法:'active'、'inactive' 或 'blocked'。
Javascript 代码:
/**
* Returns the current post status.
* @return {string} the current status: 'inactive', 'active' or 'blocked'.
*/
function getStatus() {
if (this.status === 0) return 'inactive';
if (this.status === 1) return 'active';
if (this.status === 2) return 'blocked';
}
有没有办法指定返回值?也许是这样的:
@return {string=('inactive'|'active'|'blocked')} the current status.
如果没有,我该怎么做?
【问题讨论】:
-
您是否考虑过使用 TypeScript 或 Flow?如果你想要更强的打字,那么这可能是需要考虑的事情。
-
@E.Sundin 感谢您的评论,我只想将 Jsdoc 用于文档目的。
-
@E.Sundin 在 TypeScript 中是否可行?
-
@CryptoBird - 请注意,如果需要,您可以编辑您的 cmets 而不是发布新的。
-
就我个人而言,我还没有找到此类工具的用途,所以我不知道存在什么。 Here's two typescript examples
标签: javascript documentation jsdoc jsdoc3