From 99167e24770d36b6bc4e14c75bc28d7f3409f437 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 26 Nov 2015 06:30:50 +0500 Subject: [PATCH] lodash: signatures of _.fill have been changed --- lodash/lodash-tests.ts | 57 +++++++++++++++++-- lodash/lodash.d.ts | 124 +++++++++++++++++++++++++---------------- 2 files changed, 126 insertions(+), 55 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 30c0b9934..a34d45f62 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -453,13 +453,58 @@ module TestDropWhile { } // _.fill -var testFillArray = [1, 2, 3]; -var testFillList: _.List = {0: 1, 1: 2, 2: 3, length: 3}; +module TestFill { + let array: number[]; + let list: _.List; -result = _.fill(testFillArray, 'a', 0, 3); -result = <_.List>_.fill(testFillList, 'a', 0, 3); -result = _(testFillArray).fill(0, 0, 3).value(); -result = <_.List>_(testFillList).fill(0, 0, 3).value(); + { + let result: number[]; + + result = _.fill(array, 42); + result = _.fill(array, 42, 0); + result = _.fill(array, 42, 0, 10); + } + + { + let result: _.List; + + result = _.fill(list, 42); + result = _.fill(list, 42, 0); + result = _.fill(list, 42, 0, 10); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).fill(42); + result = _(array).fill(42, 0); + result = _(array).fill(42, 0, 10); + } + + { + let result: _.LoDashImplicitObjectWrapper<_.List>; + + result = _(list).fill(42); + result = _(list).fill(42, 0); + result = _(list).fill(42, 0, 10); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().fill(42); + result = _(array).chain().fill(42, 0); + result = _(array).chain().fill(42, 0, 10); + } + + { + let result: _.LoDashExplicitObjectWrapper<_.List>; + + result = _(list).chain().fill(42); + result = _(list).chain().fill(42, 0); + result = _(list).chain().fill(42, 0, 10); + } +} // _.findIndex module TestFindIndex { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 73a783b64..dbc21db5f 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -749,6 +749,81 @@ declare module _ { ): LoDashExplicitArrayWrapper; } + //_.fill + interface LoDashStatic { + /** + * Fills elements of array with value from start up to, but not including, end. + * + * Note: This method mutates array. + * + * @param array The array to fill. + * @param value The value to fill array with. + * @param start The start position. + * @param end The end position. + * @return Returns array. + */ + fill( + array: any[], + value: T, + start?: number, + end?: number + ): T[]; + + /** + * @see _.fill + */ + fill( + array: List, + value: T, + start?: number, + end?: number + ): List; + } + + interface LoDashImplicitArrayWrapper { + /** + * @see _.fill + */ + fill( + value: T, + start?: number, + end?: number + ): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.fill + */ + fill( + value: T, + start?: number, + end?: number + ): LoDashImplicitObjectWrapper>; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.fill + */ + fill( + value: T, + start?: number, + end?: number + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.fill + */ + fill( + value: T, + start?: number, + end?: number + ): LoDashExplicitObjectWrapper>; + } + //_.findIndex interface LoDashStatic { /** @@ -4552,55 +4627,6 @@ declare module _ { ): LoDashExplicitWrapper; } - //_.fill - interface LoDashStatic { - /** - * Fills elements of array with value from start up to, but not including, end. - * - * Note: This method mutates array. - * - * @param array (Array): The array to fill. - * @param value (*): The value to fill array with. - * @param [start=0] (number): The start position. - * @param [end=array.length] (number): The end position. - * @return (Array): Returns array. - */ - fill( - array: any[], - value: any, - start?: number, - end?: number): TResult[]; - - /** - * @see _.fill - */ - fill( - array: List, - value: any, - start?: number, - end?: number): List; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.fill - */ - fill( - value: TResult, - start?: number, - end?: number): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.fill - */ - fill( - value: TResult, - start?: number, - end?: number): LoDashImplicitObjectWrapper>; - } - //_.filter interface LoDashStatic { /**