Reputation: 1829
I have this class
/**
* @constructor
* @param {...*} var_args
*/
var Map = function(var_args) {
// insert all pairs of parameters as objects in the map
};
/**
* @constructor
* @extends {Map}
* @param {...*} var_args
*/
var ExtendedMap = function(var_args) {
goog.base(this, var_args); //<-- this obviously doesn't work!
};
goog.inherits(ExtendedMap, Map);
The problem araises given that ExtendedMap
needs to extend a class (Map
) which in it's constructor already has a var_args. How do I add my own constructor without messing up with the parent's constructor? I'm using the google-closure compiler.
Upvotes: 1
Views: 236
Reputation: 9599
You don't need to use goog.base
, it is just a method to make things easier. In this case you would call the Map's constructor directly and using apply instead of call:
/**
* @constructor
* @extends {Map}
* @param {...*} var_args
*/
var ExtendedMap = function(var_args) {
Map.apply(this, arguments);
};
goog.inherits(ExtendedMap, Map);
Upvotes: 1