I made a subclass of goog.ui.Button in my Google Closure javascript.
/**
* @fileoverview This button makes a new widget.
* @author David Faux
*/
goog.provide('app.ui.NewWidgetButton');
goog.require('goog.ui.Button');
/**
* Button for creating a new widget.
* @constructor
* @param {goog.ui.ButtonRenderer=} opt_renderer Optional renderer used to
* render or decorate the button.
* @param {goog.dom.DomHelper=} opt_domHelper Optional DOM hepler, used for
* document interaction.
* @extends {goog.ui.Button}
*/
app.ui.NewWidgetButton = function(opt_renderer, opt_domHelper) {
goog.base(
this,
/** @type {goog.ui.ControlContent} */ 'New Widget',
opt_renderer,
opt_domHelper);
}
goog.inherits(app.ui.NewWidgetButton, goog.ui.Button);
However, when I instantiate this button with var newButton = app.ui.NewWidgetButton();, I get an error in Chrome Console:
`Uncaught TypeError: Object #<Object> has no method 'setContentInternal'`
I looked up the method setContentInternal, and it seemed to be a method of the class goog.ui.Control, which is a superclass of goog.ui.Button, so I am befuddled as to why this method is undefined.
The instantiation of
newButtonis missing thenewkeyword. Adding thenewkeyword fixes the error.Set the Closure Compiler flag
--warning_level=VERBOSEto generate an error such as the following: