【发布时间】:2011-08-06 22:55:36
【问题描述】:
我正在使用 ADVANCED_OPTIMIZATIONS 编译级别的 Google Closure Compiler 并已开始注释我的构造函数,因为我收到了各种警告:
警告 - 危险地使用全局 this 对象
对于我的“构造函数”类型的函数,我会这样注释它们:
/**
* Foo is my constructor
* @constructor
*/
Foo = function() {
this.member = {};
}
/**
* does something
* @this {Foo}
*/
Foo.prototype.doSomething = function() {
...
}
这似乎工作正常,但是如果我有一个不是用 var myFoo = new Foo(); 构造的“单例”对象怎么办? 我在文档中找不到如何注释这种类型的对象,因为它的类型只是对象吗?
Bar = {
member: null,
init: function() {
this.member = {};
}
};
【问题讨论】:
标签: javascript google-closure-compiler jsdoc