Thomas Allen
unread,Aug 27, 2012, 10:02:28 AM8/27/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Closure Compiler Discuss
Hi, I think that I am using @type incorrectly. I define the following
constructor:
/**
* Container widget.
*
* @constructor
* @extends {goog.ui.Container}
* @param {?goog.ui.Container.Orientation=} opt_orientation Container
* orientation; defaults to VERTICAL.
* @param {?goog.ui.ContainerRenderer=} opt_renderer Renderer used to
* render or decorate the container; defaults to
goog.ui.ContainerRenderer.
* @param {?goog.dom.DomHelper=} opt_domHelper DOM helper, used for
* document interaction.
*/
myNs.Container = function(opt_orientation, opt_renderer,
opt_domHelper) {
goog.base(this, opt_orientation, opt_renderer, opt_domHelper);
this.setRenderer(/** @type {?goog.ui.ContainerRenderer} */
opt_renderer ||
goog.ui.registry.getDefaultRenderer(this.constructor));
};
goog.inherits(myNs.Container, goog.ui.Container);
And I will see the following warning with type checking enabled:
found : (goog.ui.ContainerRenderer|goog.ui.ControlRenderer|null)
required: (goog.ui.ContainerRenderer|null)
this.setRenderer(/** @type {?goog.ui.ContainerRenderer} */
opt_renderer ||
The trouble is that goog.ui.registry.getDefaultRenderer is typed
{goog.ui.ControlRenderer?} although it has no reason to be that type
(it works fine for goog.ui.ContainerRenderer). I don't mind that very
much, because I should be able to override with the @type annotation,
right? What do I do in this case? I don't typically enable type
checking so this is my first time encountering this issue.
Thanks,
Thomas Allen