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
Michael Zhou edited this page Feb 12, 2016
·
3 revisions
A couple of useful tricks using @template.
Return the calling subtype from a super class method
/** @constructor */functionFoo(){}/** * @this {THIS} * @return {THIS} * @template THIS */Foo.prototype.method=function(){returnthis;}/** @constructor @extends {Foo} */functionBar(){}Bar.prototype=newFoo();varx=newBar().method();// x is of type "Bar"