diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 424c60375..1afd48597 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -5027,16 +5027,43 @@ var addTwoNumbers = function (x: number, y: number) { return x + y }; var plusTwo = _.bind(addTwoNumbers, null, 2); plusTwo(100); -var view = { - 'label': 'docs', - 'onClick': function () { console.log('clicked ' + this.label); } -}; +// _.bindAll +module TestBindAll { + interface SampleObject { + a: Function; + b: Function; + c: Function; + } -view = _.bindAll(view); -jQuery('#docs').on('click', view.onClick); + let object: SampleObject; -view = _(view).bindAll().value(); -jQuery('#docs').on('click', view.onClick); + { + let result: SampleObject; + + result = _.bindAll(object); + result = _.bindAll(object, 'c'); + result = _.bindAll(object, ['b'], 'c'); + result = _.bindAll(object, 'a', ['b'], 'c'); + } + + { + let result: _.LoDashImplicitObjectWrapper; + + result = _(object).bindAll(); + result = _(object).bindAll('c'); + result = _(object).bindAll(['b'], 'c'); + result = _(object).bindAll('a', ['b'], 'c'); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _(object).chain().bindAll(); + result = _(object).chain().bindAll('c'); + result = _(object).chain().bindAll(['b'], 'c'); + result = _(object).chain().bindAll('a', ['b'], 'c'); + } +} var objectBindKey = { 'name': 'moe', diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index ef6079704..cc5dea119 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -8588,24 +8588,35 @@ declare module _ { //_.bindAll interface LoDashStatic { /** - * Binds methods of an object to the object itself, overwriting the existing method. Method - * names may be specified as individual arguments or as arrays of method names. If no method - * names are provided all the function properties of object will be bound. - * @param object The object to bind and assign the bound methods to. - * @param methodNames The object method names to bind, specified as individual method names - * or arrays of method names. - * @return object - **/ + * Binds methods of an object to the object itself, overwriting the existing method. Method names may be + * specified as individual arguments or as arrays of method names. If no method names are provided all + * enumerable function properties, own and inherited, of object are bound. + * + * Note: This method does not set the "length" property of bound functions. + * + * @param object The object to bind and assign the bound methods to. + * @param methodNames The object method names to bind, specified as individual method names or arrays of + * method names. + * @return Returns object. + */ bindAll( object: T, - ...methodNames: string[]): T; + ...methodNames: (string|string[])[] + ): T; } interface LoDashImplicitObjectWrapper { /** - * @see _.bindAll - **/ - bindAll(...methodNames: string[]): LoDashImplicitWrapper; + * @see _.bindAll + */ + bindAll(...methodNames: (string|string[])[]): LoDashImplicitObjectWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.bindAll + */ + bindAll(...methodNames: (string|string[])[]): LoDashExplicitObjectWrapper; } //_.bindKey