var top = /** @type {number} */($log.scrollTop())
Should do the trick.
On Fri, Jan 11, 2013 at 6:47 PM, <
conni...@gmail.com> wrote:
> Hi,
>
> I am calling the jQuery method scrollTop as below:
> $log.scrollTop($log.scrollTop() + $log.height());
>
> I am using the extern file jquery-1.8.js that I found in
>
http://code.google.com/p/closure-compiler/source/browse/#svn%2Ftrunk%2Fcontrib%2Fexterns.
> The compiler reports such error:
>
> WARNING - actual parameter 1 of jQuery.prototype.scrollTop does not match
> formal parameter
> found : (number|string)
> required: (number|undefined)
> $log.scrollTop($log.scrollTop() + $log.height());
>
> The annotation specified in the extern file is this:
> /**
> * @param {number=} value
> * @return {(number|!jQuery)}
> */
> jQuery.prototype.scrollTop = function(value) {};
>
> I understand that this warning is reported because it cannot guarantee that
> scrollTop returns a number in this case. However, in reality, scrollTop
> always returns a number if no parameter is passed, and returns jQuery
> otherwise.
>
> Right now I suppress this error by doing something like this:
> /**
> * @type {?}
> */
> var top = $log.scrollTop();
> var height = $log.height();
> $log.scrollTop(top + height);
>
> Is there a better way to get rid of the warning?
>
> Thank you!