javascript - js-doc/google-closure-compiler 如何记录传递的枚举对象本身?

标签 javascript enums google-closure-compiler jsdoc

例如

/**
 * Super my enum
 * @enum {number}
 */
var MyEnum = {
    ONE: 1,
    TWO: 2
};

/**
 * @param {what type is it?} enumObj
 */
function showEnum(enumObj) {
  console.log(enumObj);
}

//show the enum definition object
showEnum(MyEnum);

如何将参数类型描述为 MyEnum 对象本身,而不是 MyEnum 的值/实例?

最佳答案

使用!MyEnum,其中!表示“非空”。

/**
* @param {!MyEnum} enumObj
*/
function showEnum(enumObj) {
  console.log(enumObj);
}

关于javascript - js-doc/google-closure-compiler 如何记录传递的枚举对象本身?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40531212/

相关文章:

javascript - 如何创建日期为 ("23.03.2010"的对象)

javascript - Discord.js : member. guild.channels.find 不是函数

c# - 在 WCF 数据服务中使用枚举

javascript - 使用 textangular 在内容可编辑的 div 中记录和恢复插入符号的位置

javascript - 谷歌地图的泛事件?

c# - 为什么在枚举内声明位域的组合会产生与在枚举外声明不同的结果?

java - 编写接受/返回任何枚举的枚举常量的方法

javascript - 谷歌闭包编译器不重命名属性

javascript - Closure Compiler 将 < 替换为\x3c

javascript - "goog.proto2.Message.set$Metadata"未定义错误