If initialize is the constructor, then the "this" should be name of the type not the namespace. Here is how this should be annotated for the compiler
/** @const */
var namespace = {};
/** @constructor */
namespace.a = new Class (/** @lends {namespace.a.prototype} */{
name : "test",
initialize : function() {
alert(this.name);
}
});
new namespace.a();
Here is what I have:
- a const namespace. Not required but improves type checking.
- a constructor declaration (introduces a type name)
- @lends on the object literal, indicates that the properties are being used in a type declaration.
@lends is necessary here because the Closure Compiler doesn't have any specific knowledge built in about Moo tools' Class declaration and you need to help it understand that it is being used as part of the type definition.