You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
concavelenz edited this page Nov 26, 2014
·
3 revisions
A couple of useful tricks using @template.
Return the calling subtype from a super class method
/** @constructor */
function Foo() {}
/**
* @this {THIS}
* @return {THIS}
* @template THIS
*/
Foo.prototype.method = function() {
return this;
}
/** @constructor @extends {Foo} */
function Bar() {}
Bar.prototype = new Foo();
var x = new Bar().method(); // x is of type "Bar"