From e1acbf5e84107968f9736d4fe079349fa60c0918 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Sat, 19 Dec 2015 22:42:22 +0500 Subject: [PATCH] lodash: signatures of _.bindAll have been changed --- lodash/lodash-tests.ts | 43 ++++++++++++++++++++++++++++++++++-------- lodash/lodash.d.ts | 35 ++++++++++++++++++++++------------ 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index d661839d5..31dcbcf52 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -4695,16 +4695,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 4e86afb66..61a176049 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -8103,24 +8103,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