diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 8b638ee50..2e550ee82 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -140,18 +140,18 @@ _.delay(log, 1000, 'logged later'); _.defer(function () { alert('deferred'); }); -var updatePosition = () => alert('updating position...'); +var updatePosition = (param:string) => alert('updating position... Param: ' + param); var throttled = _.throttle(updatePosition, 100); $(window).scroll(throttled); -var calculateLayout = () => alert('calculating layout...'); +var calculateLayout = (param:string) => alert('calculating layout... Param: ' + param); var lazyLayout = _.debounce(calculateLayout, 300); $(window).resize(lazyLayout); -var createApplication = () => alert('creating application...'); +var createApplication = (param:string) => alert('creating application... Param: ' + param); var initialize = _.once(createApplication); -initialize(); -initialize(); +initialize("me"); +initialize("me"); var notes: any[]; var render = () => alert("rendering..."); diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 9736c2879..2d7361dda 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -1045,10 +1045,10 @@ interface UnderscoreStatic { * @param options Allows for disabling execution of the throttled function on either the leading or trailing edge. * @return `fn` with a throttle of `wait`. **/ - throttle( - func: any, + throttle( + func: T, wait: number, - options?: _.ThrottleSettings): Function; + options?: _.ThrottleSettings): T; /** * Creates and returns a new debounced version of the passed function that will postpone its execution @@ -1064,10 +1064,10 @@ interface UnderscoreStatic { * @param immediate True if `fn` should be invoked on the leading edge of `waitMS` instead of the trailing edge. * @return Debounced version of `fn` that waits `wait` ms when invoked. **/ - debounce( - fn: Function, + debounce( + fn: T, wait: number, - immediate?: boolean): Function; + immediate?: boolean): T; /** * Creates a version of the function that can only be called one time. Repeated calls to the modified @@ -1076,7 +1076,7 @@ interface UnderscoreStatic { * @param fn Function to only execute once. * @return Copy of `fn` that can only be invoked once. **/ - once(fn: Function): Function; + once(fn: T): T; /** * Creates a version of the function that will only be run after first being called count times. Useful @@ -1086,9 +1086,9 @@ interface UnderscoreStatic { * @fn The function to defer execution `count` times. * @return Copy of `fn` that will not execute until it is invoked `count` times. **/ - after( + after( count: number, - fn: Function): Function; + fn: T): T; /** * Wraps the first function inside of the wrapper function, passing it as the first argument. This allows