-
Notifications
You must be signed in to change notification settings - Fork 1.1k
covariant subtype values with @template
Michael Zhou edited this page Feb 12, 2016
·
3 revisions
A couple of useful tricks using @template.
/** @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"