diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index adf86e9a6..b0dffe01e 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1850,12 +1850,6 @@ result = _([1, 2, 3]).sortBy(function (num) { return this.sin(num); }, result = _(['banana', 'strawberry', 'apple']).sortBy('length').value(); result = _(foodsOrganic).sortByAll('organic', (food) => food.name, { organic: true }).value(); -(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!'] }); @@ -2418,6 +2412,47 @@ result = _(1).lte(2); result = _([]).lte(2); result = _({}).lte(2); +// _.toArray +module TestToArray { + let array: TResult[]; + let list: _.List; + let dictionary: _.Dictionary; + + { + let result: string[]; + + result = _.toArray(''); + + result = (function (a: string) {return _.toArray(arguments);})(''); + + result = _((function (a: string) {return arguments;})('')).toArray().value(); + } + + { + let result: TResult[]; + + result = _.toArray(array); + result = _.toArray(list); + result = _.toArray(dictionary); + + result = _(array).toArray().value(); + result = _(list).toArray().value(); + result = _(dictionary).toArray().value(); + } + + { + let result: any[]; + + result = _.toArray(); + result = _.toArray(42); + result = _.toArray(true); + + result = _('').toArray().value(); + result = _(42).toArray().value(); + result = _(true).toArray().value(); + } +} + // _.toPlainObject module TestToPlainObject { let result: TResult; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index d5463ffc0..c77ff2f17 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -5649,40 +5649,6 @@ declare module _ { orders?: string[]): LoDashArrayWrapper; } - //_.toArray - interface LoDashStatic { - /** - * Converts the collection to an array. - * @param collection The collection to convert. - * @return The new converted array. - **/ - toArray(collection: Array): T[]; - - /** - * @see _.toArray - **/ - toArray(collection: List): T[]; - - /** - * @see _.toArray - **/ - toArray(collection: Dictionary): T[]; - } - - interface LoDashArrayWrapper { - /** - * @see _.toArray - **/ - toArray(): LoDashArrayWrapper; - } - - interface LoDashObjectWrapper { - /** - * @see _.toArray - **/ - toArray(): LoDashArrayWrapper; - } - //_.where interface LoDashStatic { /** @@ -7068,6 +7034,58 @@ declare module _ { lte(other: any): boolean; } + //_.toArray + interface LoDashStatic { + /** + * Converts value to an array. + * + * @param value The value to convert. + * @return Returns the converted array. + */ + toArray(value: string): string[]; + + /** + * @see _.toArray + */ + toArray(value: List|Dictionary): T[]; + + /** + * @see _.toArray + */ + toArray(value: TValue): TResult[]; + + /** + * @see _.toArray + */ + toArray(value: TValue): any[]; + + /** + * @see _.toArray + */ + toArray(value?: any): any[]; + } + + interface LoDashWrapper { + /** + * @see _.toArray + */ + toArray(): LoDashArrayWrapper; + } + + interface LoDashArrayWrapper { + /** + * @see _.toArray + */ + toArray(): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.toArray + */ + toArray(): LoDashArrayWrapper; + } + //_.toPlainObject interface LoDashStatic { /**