diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 79b5515a35..26718207d8 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -240,6 +240,10 @@ _.object([['moe', 30], ['larry', 40], ['curly', 50]]); _.indexOf([1, 2, 3], 2); _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); _.sortedIndex([10, 20, 30, 40, 50], 35); +_.findIndex([1, 2, 3, 1, 2, 3], num => num % 2 === 0); +_.findIndex([{a: 'a'}, {a: 'b'}], {a: 'b'}); +_.findLastIndex([1, 2, 3, 1, 2, 3], num => num % 2 === 0); +_.findLastIndex([{ a: 'a' }, { a: 'b' }], { a: 'b' }); _.range(10); _.range(1, 11); _.range(0, 30, 5); diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index fb7ff79437..4b4f9da700 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -305,21 +305,6 @@ interface UnderscoreStatic { object: _.List|_.Dictionary, iterator: string): T; - /** - * Looks through each value in the list, returning the index of the first one that passes a truth - * test (iterator). The function returns as soon as it finds an acceptable element, - * and doesn't traverse the entire list. - * @param list Searches for a value in this list. - * @param iterator Search iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return The index of the first acceptable found element in `list`, if nothing is found -1 is returned. - **/ - findIndex( - list: _.List, - iterator: _.ListIterator, - context?: any): number; - - /** * Looks through each value in the list, returning an array of all the values that pass a truth * test (iterator). Delegates to the native filter method, if it exists. @@ -1014,7 +999,7 @@ interface UnderscoreStatic { **/ findIndex( array: _.List, - predicate: _.ListIterator, + predicate: _.ListIterator | {}, context?: any): number; /** @@ -1026,7 +1011,7 @@ interface UnderscoreStatic { **/ findLastIndex( array: _.List, - predicate: _.ListIterator, + predicate: _.ListIterator | {}, context?: any): number; /** @@ -4499,12 +4484,12 @@ interface Underscore { /** * @see _.findIndex **/ - findIndex(array: _.List, predicate: _.ListIterator, context?: any): number; + findIndex(array: _.List, predicate: _.ListIterator | {}, context?: any): number; /** * @see _.findLastIndex **/ - findLastIndex(array: _.List, predicate: _.ListIterator, context?: any): number; + findLastIndex(array: _.List, predicate: _.ListIterator | {}, context?: any): number; /** * Wrapped type `any[]`. @@ -5417,12 +5402,12 @@ interface _Chain { /** * @see _.findIndex **/ - findIndex(predicate: _.ListIterator, context?: any): _Chain; + findIndex(predicate: _.ListIterator | {}, context?: any): _ChainSingle; /** * @see _.findLastIndex **/ - findLastIndex(predicate: _.ListIterator, context?: any): _Chain; + findLastIndex(predicate: _.ListIterator | {}, context?: any): _ChainSingle; /** * Wrapped type `any[]`.