diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index d58368b794..cc4ab44085 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -425,9 +425,17 @@ result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function (num) { ret result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function (num) { return this.floor(num); }, Math); result = <_.Dictionary>_.groupBy(['one', 'two', 'three'], 'length'); -result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return Math.floor(num); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return this.floor(num); }, Math); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).groupBy('length'); +result = <_.Dictionary>_.groupBy({ prop1: 4.2, prop2: 6.1, prop3: 6.4}, function (num) { return Math.floor(num); }); +result = <_.Dictionary>_.groupBy({ prop1: 4.2, prop2: 6.1, prop3: 6.4}, function (num) { return this.floor(num); }, Math); +result = <_.Dictionary>_.groupBy({ prop1: 'one', prop2: 'two', prop3: 'three'}, 'length'); + +result = <_.Dictionary>_([4.2, 6.1, 6.4]).groupBy(function (num) { return Math.floor(num); }).value(); +result = <_.Dictionary>_([4.2, 6.1, 6.4]).groupBy(function (num) { return this.floor(num); }, Math).value(); +result = <_.Dictionary>_(['one', 'two', 'three']).groupBy('length').value(); + +result = <_.Dictionary>_({ prop1: 4.2, prop2: 6.1, prop3: 6.4}).groupBy(function (num) { return Math.floor(num); }).value(); +result = <_.Dictionary>_({ prop1: 4.2, prop2: 6.1, prop3: 6.4}).groupBy(function (num) { return this.floor(num); }, Math).value(); +result = <_.Dictionary>_({ prop1: 'one', prop2: 'two', prop3: 'three'}).groupBy('length').value(); result = <_.Dictionary>_.indexBy(keys, 'dir'); result = <_.Dictionary>_.indexBy(keys, function (key) { return String.fromCharCode(key.code); }); @@ -556,7 +564,11 @@ result = _([1, 2, 3]).sortBy(function (num) { return Math.sin(num); }) result = _([1, 2, 3]).sortBy(function (num) { return this.sin(num); }, Math).value(); result = _(['banana', 'strawberry', 'apple']).sortBy('length').value(); -(function (a: number, b: number, c: number, d: number) { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); +(function (a: number, b: number, c: number, d: number): Array { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); +result = _.toArray([1, 2, 3, 4]); +(function (a: number, b: number, c: number, d: number): Array { return _(arguments).toArray().slice(1).value(); })(1, 2, 3, 4); +result = _([1,2,3,4]).toArray().value(); + result = _.where(stoogesCombined, { 'age': 40 }); result = _.where(stoogesCombined, { 'quotes': ['Poifect!'] }); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index e51a598252..24e55836ae 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -3169,6 +3169,30 @@ declare module _ { groupBy( collection: List, whereValue: W): Dictionary; + + /** + * @see _.groupBy + **/ + groupBy( + collection: Dictionary, + callback?: ListIterator, + thisArg?: any): Dictionary; + + /** + * @see _.groupBy + * @param pluckValue _.pluck style callback + **/ + groupBy( + collection: Dictionary, + pluckValue: string): Dictionary; + + /** + * @see _.groupBy + * @param whereValue _.where style callback + **/ + groupBy( + collection: Dictionary, + whereValue: W): Dictionary; } interface LoDashArrayWrapper { @@ -3177,19 +3201,40 @@ declare module _ { **/ groupBy( callback: ListIterator, - thisArg?: any): _.LoDashObjectWrapper>; + thisArg?: any): _.LoDashObjectWrapper<_.Dictionary>; /** * @see _.groupBy **/ groupBy( - pluckValue: string): _.LoDashObjectWrapper>; + pluckValue: string): _.LoDashObjectWrapper<_.Dictionary>; /** * @see _.groupBy **/ groupBy( - whereValue: W): _.LoDashObjectWrapper>; + whereValue: W): _.LoDashObjectWrapper<_.Dictionary>; + } + + interface LoDashObjectWrapper { + /** + * @see _.groupBy + **/ + groupBy( + callback: ListIterator, + thisArg?: any): _.LoDashObjectWrapper<_.Dictionary>; + + /** + * @see _.groupBy + **/ + groupBy( + pluckValue: string): _.LoDashObjectWrapper<_.Dictionary>; + + /** + * @see _.groupBy + **/ + groupBy( + whereValue: W): _.LoDashObjectWrapper<_.Dictionary>; } //_.indexBy @@ -4520,6 +4565,20 @@ declare module _ { toArray(collection: Dictionary): T[]; } + interface LoDashArrayWrapper { + /** + * @see _.toArray + **/ + toArray(): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.toArray + **/ + toArray(): LoDashArrayWrapper; + } + //_.where interface LoDashStatic { /**