diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index e7e827300..aa790ce4c 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -297,11 +297,41 @@ module TestFindIndex { result = _(list).findIndex<{a: number}>({a: 42}); } -result = _.findLastIndex(['apple', 'banana', 'beet'], function (f: string) { - return /^b/.test(f); -}); -result = _.findLastIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findLastIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple' }); +// _.findLastIndex +module TestFindLastIndex { + let array: TResult[]; + let list: _.List; + let predicateFn: (value: TResult, index?: number, collection?: _.List) => boolean; + let result: number; + + result = _.findLastIndex(array); + result = _.findLastIndex(array, predicateFn); + result = _.findLastIndex(array, predicateFn, any); + result = _.findLastIndex(array, ''); + result = _.findLastIndex(array, '', any); + result = _.findLastIndex<{a: number}, TResult>(array, {a: 42}); + + result = _.findLastIndex(list); + result = _.findLastIndex(list, predicateFn); + result = _.findLastIndex(list, predicateFn, any); + result = _.findLastIndex(list, ''); + result = _.findLastIndex(list, '', any); + result = _.findLastIndex<{a: number}, TResult>(list, {a: 42}); + + result = _(array).findLastIndex(); + result = _(array).findLastIndex(predicateFn); + result = _(array).findLastIndex(predicateFn, any); + result = _(array).findLastIndex(''); + result = _(array).findLastIndex('', any); + result = _(array).findLastIndex<{a: number}>({a: 42}); + + result = _(list).findLastIndex(); + result = _(list).findLastIndex(predicateFn); + result = _(list).findLastIndex(predicateFn, any); + result = _(list).findLastIndex(''); + result = _(list).findLastIndex('', any); + result = _(list).findLastIndex<{a: number}>({a: 42}); +} // _.first module TestFirst { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 10171fd57..84a120f3b 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -554,53 +554,94 @@ declare module _ { //_.findLastIndex interface LoDashStatic { /** - * This method is like _.findIndex except that it iterates over elements of a collection from right to left. - * @param array The array to search. - * @param {(Function|Object|string)} callback The function called per iteration. If a property name or object is provided it will be - * used to create a ".pluck" or ".where" style callback, respectively. - * @param thisArg The this binding of callback. - * @return Returns the index of the found element, else -1. - **/ - findLastIndex( - array: Array, - callback: ListIterator, - thisArg?: any): number; - - /** - * @see _.findLastIndex - **/ + * This method is like _.findIndex except that it iterates over elements of collection from right to left. + * + * If a property name is provided for predicate the created _.property style callback returns the property + * value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for + * elements that have a matching property value, else false. + * + * If an object is provided for predicate the created _.matches style callback returns true for elements that + * have the properties of the given object, else false. + * + * @param array The array to search. + * @param predicate The function invoked per iteration. + * @param thisArg The function invoked per iteration. + * @return Returns the index of the found element, else -1. + */ findLastIndex( array: List, - callback: ListIterator, - thisArg?: any): number; + predicate?: ListIterator, + thisArg?: any + ): number; /** - * @see _.findLastIndex - **/ - findLastIndex( - array: Array, - pluckValue: string): number; - - /** - * @see _.findLastIndex - **/ + * @see _.findLastIndex + */ findLastIndex( array: List, - pluckValue: string): number; + predicate?: string, + thisArg?: any + ): number; /** - * @see _.findLastIndex - **/ - findLastIndex( - array: Array, - whereDictionary: Dictionary): number; - - /** - * @see _.findLastIndex - **/ - findLastIndex( + * @see _.findLastIndex + */ + findLastIndex( array: List, - whereDictionary: Dictionary): number; + predicate?: W + ): number; + } + + interface LoDashArrayWrapper { + /** + * @see _.findLastIndex + */ + findLastIndex( + predicate?: ListIterator, + thisArg?: any + ): number; + + /** + * @see _.findLastIndex + */ + findLastIndex( + predicate?: string, + thisArg?: any + ): number; + + /** + * @see _.findLastIndex + */ + findLastIndex( + predicate?: W + ): number; + } + + interface LoDashObjectWrapper { + /** + * @see _.findLastIndex + */ + findLastIndex( + predicate?: ListIterator, + thisArg?: any + ): number; + + /** + * @see _.findLastIndex + */ + findLastIndex( + predicate?: string, + thisArg?: any + ): number; + + /** + * @see _.findLastIndex + */ + findLastIndex( + predicate?: W + ): number; } //_.first