diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 45248b829c..7bdd7a8621 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1735,11 +1735,6 @@ class Mage { } } -var mage = new Mage(); -result = _.times(3, <() => number>_.partial(_.random, 1, 6)); -result = _.times(3, function (n: number) { mage.castSpell(n); }); -result = _.times(3, function (n: number) { this.cast(n); }, mage); - result = _.uniqueId('contact_'); result = _.uniqueId(); @@ -1948,3 +1943,18 @@ result = (_(TestMethodOfObject).methodOf(1, 2).value())(['a', '0 result = _.VERSION; result = <_.Support>_.support; result = <_.TemplateSettings>_.templateSettings; + +// _.times +{ + let result: number[]; + result = _.times(42); + result = _(42).times().value(); +} +{ + let testTimesFn: (num: number) => TResult; + let result: TResult[]; + result = _.times(42, testTimesFn); + result = _.times(42, testTimesFn, any); + result = _(42).times(testTimesFn).value(); + result = _(42).times(testTimesFn, any).value(); +} diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 92b621ab23..5c192d5c36 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -8300,16 +8300,39 @@ declare module _ { //_.times interface LoDashStatic { /** - * Executes the callback n times, returning an array of the results of each callback execution. - * The callback is bound to thisArg and invoked with one argument; (index). - * @param n The number of times to execute the callback. - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - **/ + * Invokes the iteratee function n times, returning an array of the results of each invocation. The iteratee is + * bound to thisArg and invoked with one argument; (index). + * + * @param n The number of times to invoke iteratee. + * @param iteratee The function invoked per iteration. + * @param thisArg The this binding of iteratee. + * @return Returns the array of results. + */ times( n: number, - callback: (num: number) => TResult, - context?: any): TResult[]; + iteratee: (num: number) => TResult, + thisArg?: any + ): TResult[]; + + /** + * @see _.times + */ + times(n: number): number[]; + } + + interface LoDashWrapper { + /** + * @see _.times + */ + times( + iteratee: (num: number) => TResult, + thisArgs?: any + ): LoDashArrayWrapper; + + /** + * @see _.times + */ + times(): LoDashArrayWrapper; } //_.uniqueId