From 67e0a6003cb440cc5d0438ba57691e1f88319628 Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Mon, 11 Nov 2013 06:57:38 -0800 Subject: [PATCH] remove any types and improve callback inference --- lodash/lodash-tests.ts | 199 ++++++++------ lodash/lodash.d.ts | 595 ++++++++++++----------------------------- 2 files changed, 281 insertions(+), 513 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 400d8664a..cff8a443d 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -229,9 +229,9 @@ result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); result = <{[key: string]: any}>_.zipObject(['moe', 'larry'], [30, 40]); - result = <{[key: string]: any}>_.object(['moe', 'larry'], [30, 40]); +result = <{[key: string]: any}>_.object(['moe', 'larry'], [30, 40]); -result = _.pull([1, 2, 3, 1, 2, 3], 2, 3); +result = _.pull([1, 2, 3, 1, 2, 3], 2, 3); result = _.range(10); result = _.range(1, 11); @@ -277,7 +277,7 @@ result = <{x: number;}[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); result = _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); result = _.zip(['moe', 'larry'], [30, 40], [true, false]); - result = _.unzip(['moe', 'larry'], [30, 40], [true, false]); +result = _.unzip(['moe', 'larry'], [30, 40], [true, false]); // /* ************* // * Collections * @@ -388,16 +388,16 @@ result = <_.Dictionary>_.indexBy(keys, 'dir'); result = <_.Dictionary>_.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); result = <_.Dictionary>_.indexBy(keys, function(key) { this.fromCharCode(key.code); }, String); -result = _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); -result = _.invoke([123, 456], String.prototype.split, ''); +result = _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); +result = _.invoke([123, 456], String.prototype.split, ''); -result = _.map([1, 2, 3], function(num) { return num * 3; }); -result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); -result = _.map(stoogesAges, 'name'); +result = _.map([1, 2, 3], function(num) { return num * 3; }); +result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); +result = _.map(stoogesAges, 'name'); - result = _.collect([1, 2, 3], function(num) { return num * 3; }); - result = _.collect({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); - result = _.collect(stoogesAges, 'name'); +result = _.collect([1, 2, 3], function(num) { return num * 3; }); +result = _.collect({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); +result = _.collect(stoogesAges, 'name'); result = _.max([4, 2, 8, 6]); result = _.max(stoogesAges, function(stooge) { return stooge.age; }); @@ -412,29 +412,34 @@ result = _.pluck(stoogesAges, 'name'); result = _.reduce([1, 2, 3], function(sum: number, num: number) { return sum + num; }); -result = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(r: any, num: number, key: string) { +interface ABC { + a: number; + b: number; + c: number; +} +result = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { r[key] = num * 3; return r; }, {}); - result = _.foldl([1, 2, 3], function(sum: number, num: number) { - return sum + num; - }); - result = _.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function(r: any, num: number, key: string) { - r[key] = num * 3; - return r; - }, {}); +result = _.foldl([1, 2, 3], function(sum, num) { + return sum + num; +}); +result = _.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { + r[key] = num * 3; + return r; +}, {}); - result = _.inject([1, 2, 3], function(sum: number, num: number) { - return sum + num; - }); - result = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function(r: any, num: number, key: string) { - r[key] = num * 3; - return r; - }, {}); +result = _.inject([1, 2, 3], function(sum, num) { + return sum + num; +}); +result = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { + r[key] = num * 3; + return r; +}, {}); -result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); - result = _.foldr([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); +result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); +result = _.foldr([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); result = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); result = _.reject(foodsCombined, 'organic'); @@ -453,15 +458,15 @@ result = _.some([null, 0, 'yes', false], Boolean); result = _.some(foodsCombined, 'organic'); result = _.some(foodsCombined, { 'type': 'meat' }); - result = _.any([null, 0, 'yes', false], Boolean); - result = _.any(foodsCombined, 'organic'); - result = _.any(foodsCombined, { 'type': 'meat' }); +result = _.any([null, 0, 'yes', false], Boolean); +result = _.any(foodsCombined, 'organic'); +result = _.any(foodsCombined, { 'type': 'meat' }); result = _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); result = _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); result = _.sortBy(['banana', 'strawberry', 'apple'], 'length'); -(function(a: any, b: any, c: any, d: any){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); +(function(a: number, b: number, c: number, d: number){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); result = _.where(stoogesCombined, { 'age': 40 }); result = _.where(stoogesCombined, { 'quotes': ['Poifect!'] }); @@ -634,40 +639,48 @@ helloWrap2(); /********** * Objects * ***********/ -result = _.assign({ 'name': 'moe' }, { 'age': 40 }); -result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function(a: any, b: any) { +interface NameAge { + name: string; + age: number; +} +result = _.assign({ 'name': 'moe' }, { 'age': 40 }); +result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { return typeof a == 'undefined' ? b : a; }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a: any, b: any) { +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }); +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a, b) { return typeof a == 'undefined' ? b : a; }); - result = _.extend({ 'name': 'moe' }, { 'age': 40 }); - result = _.extend({ 'name': 'moe' }, { 'age': 40 }, function(a: any, b: any) { - return typeof a == 'undefined' ? b : a; - }); +result = _.extend({ 'name': 'moe' }, { 'age': 40 }); +result = _.extend({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { + return typeof a == 'undefined' ? b : a; +}); - result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }); - result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a: any, b: any) { - return typeof a == 'undefined' ? b : a; - }); +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }); +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a, b) { + return typeof a == 'undefined' ? b : a; +}); -var result = _.clone(stoogesAges); -var result = _.clone(stoogesAges, true); -var result = _.clone(stoogesAges, true, function(value) { +result = _.clone(stoogesAges); +result = _.clone(stoogesAges, true); +result = _.clone(stoogesAges, true, function(value) { return _.isElement(value) ? value.cloneNode(false) : undefined; }); -var result = _.cloneDeep(stoogesAges); -var result = _.cloneDeep(stoogesAges, function(value) { +result = _.cloneDeep(stoogesAges); +result = _.cloneDeep(stoogesAges, function(value) { return _.isElement(value) ? value.cloneNode(false) : undefined; }); +interface Food { + name: string; + type: string; +} var foodDefaults = { 'name': 'apple' }; -result = _.defaults(foodDefaults, { 'name': 'banana', 'type': 'fruit' }); -result = _(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' }); +result = _.defaults(foodDefaults, { 'name': 'banana', 'type': 'fruit' }); + result = <_.LoDashObjectWrapper>_(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' }); result = _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { return num % 2 == 0; @@ -677,27 +690,33 @@ result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) return num % 2 == 1; }); -result = _.forIn(new Dog('Dagny'), function(value, key) { +result = _.forIn(new Dog('Dagny'), function(value, key) { console.log(key); }); - result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forIn(function(value, key) { - console.log(key); - }); - -result = _.forInRight(new Dog('Dagny'), function(value, key) { +result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forIn(function(value, key) { console.log(key); }); - result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forInRight(function(value, key) { - console.log(key); - }); - -result = _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { +result = _.forInRight(new Dog('Dagny'), function(value, key) { console.log(key); }); - result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function(num, key) { +result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forInRight(function(value, key) { + console.log(key); +}); + +interface ZeroOne { + 0: string; + 1: string; + one: string; +} + +result = _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + console.log(key); +}); + + result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function(num, key) { console.log(key); }); @@ -705,19 +724,23 @@ result = _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(n console.log(key); }); - result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function(num, key) { + result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function(num, key) { console.log(key); }); result = _.functions(_); - result = _.methods(_); +result = _.methods(_); - result = <_.LoDashArrayWrapper>_(_).functions(); - result = <_.LoDashArrayWrapper>_(_).methods(); +result = <_.LoDashArrayWrapper>_(_).functions(); +result = <_.LoDashArrayWrapper>_(_).methods(); result = _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); -result = _.invert({ 'first': 'moe', 'second': 'larry' }); +interface FirstSecond { + first: string; + second: string; +} +result = _.invert({ 'first': 'moe', 'second': 'larry' }); (function(...args: any[]) { return _.isArguments(arguments); })(1, 2, 3); @@ -804,7 +827,7 @@ var mergeAges = { ] }; -result = _.merge(mergeNames, mergeAges); +result = _.merge(mergeNames, mergeAges); var mergeFood = { 'fruits': ['apple'], @@ -816,25 +839,33 @@ var mergeOtherFood = { 'vegetables': ['carrot'] }; -result = _.merge(mergeFood, mergeOtherFood, function(a: any, b: any) { +interface FruitVeg { + fruits: string[]; + vegetables: string[] +}; + +result = _.merge(mergeFood, mergeOtherFood, function(a, b) { return _.isArray(a) ? a.concat(b) : undefined; }); -result = _.omit({ 'name': 'moe', 'age': 40 }, 'age'); -result = _.omit({ 'name': 'moe', 'age': 40 }, ['age']); -result = _.omit({ 'name': 'moe', 'age': 40 }, function(value) { +interface HasName { + name: string; +} +result = _.omit({ 'name': 'moe', 'age': 40 }, 'age'); +result = _.omit({ 'name': 'moe', 'age': 40 }, ['age']); +result = _.omit({ 'name': 'moe', 'age': 40 }, function(value) { return typeof value == 'number'; }); result = _.pairs({ 'moe': 30, 'larry': 40 }); -result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name'); -result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, ['name']); -result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { +result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name'); +result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, ['name']); +result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { return key.charAt(0) != '_'; }); -result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(r: any, num: number) { +result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(r, num) { num *= num; if (num % 2) { return r.push(num) < 3; @@ -842,11 +873,11 @@ result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(r: any, num: }); // → [1, 9, 25] -result = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(r: any, num: number, key: string) { +result = <{a:number;b:number;c:number;}>_.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(r, num, key) { r[key] = num * 3; }); -result = _.values({ 'one': 1, 'two': 2, 'three': 3 }); +result = _.values({ 'one': 1, 'two': 2, 'three': 3 }); /********** * Utilities * @@ -879,8 +910,8 @@ var object = { } }; -result = _.result(object, 'cheese'); -result = _.result(object, 'stuff'); +result = _.result(object, 'cheese'); +result = _.result(object, 'stuff'); var tempObject = {}; result = _.runInContext(tempObject); @@ -911,9 +942,9 @@ class Mage { } var mage = new Mage(); -result = _.times(3, _.partial(_.random, 1, 6)); -result = _.times(3, function(n: number) { mage.castSpell(n); }); -result = _.times(3, function(n: number) { this.cast(n); }, mage); +result = _.times(3, _.partial(_.random, 1, 6)); +result = _.times(3, function(n: number) { mage.castSpell(n); }); +result = _.times(3, function(n: number) { this.cast(n); }, mage); result = _.unescape('Moe, Larry & Curly'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 98c7f11cc..92095acc8 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2023,7 +2023,7 @@ declare module _ { reduce( collection: Collection, callback: MemoIterator, - accumulator?: TResult, + accumulator: TResult, thisArg?: any): TResult; /** @@ -2040,7 +2040,7 @@ declare module _ { inject( collection: Collection, callback: MemoIterator, - accumulator?: TResult, + accumulator: TResult, thisArg?: any): TResult; /** @@ -2057,7 +2057,7 @@ declare module _ { foldl( collection: Collection, callback: MemoIterator, - accumulator?: TResult, + accumulator: TResult, thisArg?: any): TResult; /** @@ -2083,7 +2083,7 @@ declare module _ { reduceRight( collection: Collection, callback: MemoIterator, - accumulator?: TResult, + accumulator: TResult, thisArg?: any): TResult; /** @@ -2100,7 +2100,7 @@ declare module _ { foldr( collection: Collection, callback: MemoIterator, - accumulator?: TResult, + accumulator: TResult, thisArg?: any): TResult; /** @@ -2739,388 +2739,172 @@ declare module _ { * @param thisArg The this binding of callback. * @return The destination object. **/ - assign( - object: T, - s1: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; + assign( + object: T, + s1: S1, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; /** * @see _.assign **/ - assign( - object: T, - s1: any, - s2: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.assign - **/ - assign( - object: T, - s1: any, - s2: any, - s3: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; + assign( + object: T, + s1: S1, + s2: S2, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; /** * @see _.assign **/ - assign( - object: T, - s1: any, - s2: any, - s3: any, - s4: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; + assign( + object: T, + s1: S1, + s2: S2, + s3: S3, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; /** * @see _.assign **/ - assign( - object: T, - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; + assign( + object: T, + s1: S1, + s2: S2, + s3: S3, + s4: S4, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; /** * @see _.assign **/ - assign( - object: T, - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; + extend( + object: T, + s1: S1, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; /** * @see _.assign **/ - assign( - object: T, - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - s7: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; + extend( + object: T, + s1: S1, + s2: S2, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; /** * @see _.assign **/ - assign( - object: T, - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - s7: any, - s8: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.extend - **/ - extend( - object: T, - s1: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.extend - **/ - extend( - object: T, - s1: any, - s2: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.extend - **/ - extend( - object: T, - s1: any, - s2: any, - s3: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.extend - **/ - extend( - object: T, - s1: any, - s2: any, - s3: any, - s4: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.extend - **/ - extend( - object: T, - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.extend - **/ - extend( - object: T, - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.extend - **/ - extend( - object: T, - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - s7: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.extend - **/ - extend( - object: T, - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - s7: any, - s8: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; + extend( + object: T, + s1: S1, + s2: S2, + s3: S3, + s4: S4, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; } interface LoDashObjectWrapper { /** * @see _.assign **/ - assign( - s1: any, - callback?: (objectValue: any, sourceValue: any) => any, + assign( + s1: S1, + callback?: (objectValue: Value, sourceValue: Value) => Value, thisArg?: any): TResult; /** * @see _.assign **/ - assign( - s1: any, - s2: any, - callback?: (objectValue: any, sourceValue: any) => any, + assign( + s1: S1, + s2: S2, + callback?: (objectValue: Value, sourceValue: Value) => Value, thisArg?: any): TResult; - - /** - * @see _.assign - **/ - assign( - s1: any, - s2: any, - s3: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - /** * @see _.assign **/ - assign( - s1: any, - s2: any, - s3: any, - s4: any, - callback?: (objectValue: any, sourceValue: any) => any, + assign( + s1: S1, + s2: S2, + s3: S3, + callback?: (objectValue: Value, sourceValue: Value) => Value, thisArg?: any): TResult; - /** * @see _.assign **/ - assign( - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - callback?: (objectValue: any, sourceValue: any) => any, + assign( + s1: S1, + s2: S2, + s3: S3, + s4: S4, + callback?: (objectValue: Value, sourceValue: Value) => Value, thisArg?: any): TResult; - /** * @see _.assign **/ - assign( - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - callback?: (objectValue: any, sourceValue: any) => any, + assign( + s1: S1, + s2: S2, + s3: S3, + s4: S4, + s5: S5, + callback?: (objectValue: Value, sourceValue: Value) => Value, thisArg?: any): TResult; - /** - * @see _.assign - **/ - assign( - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - s7: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; - /** - * @see _.assign - **/ - assign( - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - s7: any, - s8: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + s3: S3, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + s3: S3, + s4: S4, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + s3: S3, + s4: S4, + s5: S5, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; - /** - * @see _.assign - **/ - extend( - s1: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.assign - **/ - extend( - s1: any, - s2: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.assign - **/ - extend( - s1: any, - s2: any, - s3: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.assign - **/ - extend( - s1: any, - s2: any, - s3: any, - s4: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.assign - **/ - extend( - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.assign - **/ - extend( - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.assign - **/ - extend( - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - s7: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; - - /** - * @see _.assign - **/ - extend( - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - s7: any, - s8: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): TResult; } //_.clone @@ -3261,7 +3045,7 @@ declare module _ { * @param thisArg The this binding of callback. * @return object **/ - forIn( + forIn( object: Dictionary, callback?: ObjectIterator, thisArg?: any): Dictionary; @@ -3627,102 +3411,44 @@ declare module _ { * @param thisArg The this binding of callback. * @return The destination object. **/ - merge( - object: any, - s1: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): any; + merge( + object: T, + s1: S1, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; /** * @see _.merge **/ - merge( - object: any, - s1: any, - s2: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): any; + merge( + object: T, + s1: S1, + s2: S2, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; /** * @see _.merge **/ - merge( - object: any, - s1: any, - s2: any, - s3: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): any; + merge( + object: T, + s1: S1, + s2: S2, + s3: S3, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; /** * @see _.merge **/ - merge( - object: any, - s1: any, - s2: any, - s3: any, - s4: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): any; - - /** - * @see _.merge - **/ - merge( - object: any, - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): any; - - /** - * @see _.merge - **/ - merge( - object: any, - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): any; - - /** - * @see _.merge - **/ - merge( - object: any, - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - s7: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): any; - - /** - * @see _.merge - **/ - merge( - object: any, - s1: any, - s2: any, - s3: any, - s4: any, - s5: any, - s6: any, - s7: any, - s8: any, - callback?: (objectValue: any, sourceValue: any) => any, - thisArg?: any): any; + merge( + object: T, + s1: S1, + s2: S2, + s3: S3, + s4: S4, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; } //_.omit @@ -3814,19 +3540,19 @@ declare module _ { * @param thisArg The this binding of callback. * @return The accumulated value. **/ - transform( + transform( collection: Collection, - callback?: MemoIterator, - accumulator?: any, - thisArg?: any): any; + callback: MemoVoidIterator, + accumulator: Acc, + thisArg?: any): Acc; /** * @see _.transform **/ - transform( + transform( collection: Collection, - callback?: MemoIterator, - thisArg?: any): any; + callback?: MemoVoidIterator, + thisArg?: any): Acc; } //_.values @@ -4027,9 +3753,20 @@ declare module _ { (element: T, key: string, list: any): TResult; } + interface MemoVoidIterator { + (prev: TResult, curr: T, indexOrKey: any, list?: T[]): void; + } interface MemoIterator { (prev: TResult, curr: T, indexOrKey: any, list?: T[]): TResult; } + /* + interface MemoListIterator { + (prev: TResult, curr: T, index: number, list?: T[]): TResult; + } + interface MemoObjectIterator { + (prev: TResult, curr: T, index: string, object?: Dictionary): TResult; + } + */ interface Collection { } @@ -4042,4 +3779,4 @@ declare module _ { interface Dictionary extends Collection { [index: string]: T; } -} \ No newline at end of file +}