如果具有如下所示的枚举:
/** @enum {number} */
let IntType = {
EVEN: 0,ODD: 1
};
如果这是文件中的全部内容,并且我在JS文档中的其他任何地方(例如IntType
)引用了/** @type {IntType} */
,则VS Code intellisense显示“ type IntType = number”。但是,如果我以任何方式导出它,突然之间VS Code只会显示“ any”作为类型。我已经尝试了以下所有方法来导出此文件:
// Assigning object to module.exports
module.exports = IntType;
// Assigning as a member of module.exports
module.exports = {
IntType
};
// or
module.exports.IntType = IntType;
// Defined in the export itself
/** @enum {number} */
module.exports = {
EVEN: 0,ODD: 1
};
如何将该对象记录为枚举并将其导出,以便可以在其他文件中使用它?