diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 6733f77d4..9a2cb6fb3 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2013,28 +2013,43 @@ result = _(TestDefaultsDeepObject).defaultsDeep boolean; let result: string; - result = _.findKey<{a: string;}>({a: ''}); + { + let predicateFn: (value: any, key?: string, object?: {}) => boolean; - result = _.findKey<{a: string;}>({a: ''}, predicateFn); - result = _.findKey<{a: string;}>({a: ''}, predicateFn, any); + result = _.findKey<{a: string;}>({a: ''}); - result = _.findKey<{a: string;}>({a: ''}, ''); - result = _.findKey<{a: string;}>({a: ''}, '', any); + result = _.findKey<{a: string;}>({a: ''}, predicateFn); + result = _.findKey<{a: string;}>({a: ''}, predicateFn, any); - result = _.findKey<{a: number;}, {a: string;}>({a: ''}, {a: 42}); - result = _<{a: string;}>({a: ''}).findKey(); + result = _.findKey<{a: string;}>({a: ''}, ''); + result = _.findKey<{a: string;}>({a: ''}, '', any); - result = _<{a: string;}>({a: ''}).findKey(predicateFn); - result = _<{a: string;}>({a: ''}).findKey(predicateFn, any); + result = _.findKey<{a: number;}, {a: string;}>({a: ''}, {a: 42}); - result = _<{a: string;}>({a: ''}).findKey(''); - result = _<{a: string;}>({a: ''}).findKey('', any); + result = _<{a: string;}>({a: ''}).findKey(); - result = _<{a: string;}>({a: ''}).findKey<{a: number;}>({a: 42}); + result = _<{a: string;}>({a: ''}).findKey(predicateFn); + result = _<{a: string;}>({a: ''}).findKey(predicateFn, any); + + + result = _<{a: string;}>({a: ''}).findKey(''); + result = _<{a: string;}>({a: ''}).findKey('', any); + + result = _<{a: string;}>({a: ''}).findKey<{a: number;}>({a: 42}); + } + + { + let predicateFn: (value: string, key?: string, collection?: _.Dictionary) => boolean; + + result = _.findKey({a: ''}, predicateFn); + result = _.findKey({a: ''}, predicateFn, any); + + result = _<{a: string;}>({a: ''}).findKey(predicateFn); + result = _<{a: string;}>({a: ''}).findKey(predicateFn, any); + } } result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index e7411f3a9..37a2808a2 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7104,6 +7104,15 @@ declare module _ { * @param thisArg The this binding of predicate. * @return Returns the key of the matched element, else undefined. */ + findKey( + object: TObject, + predicate?: DictionaryIterator, + thisArg?: any + ): string; + + /** + * @see _.findKey + */ findKey( object: TObject, predicate?: ObjectIterator, @@ -7129,6 +7138,14 @@ declare module _ { } interface LoDashObjectWrapper { + /** + * @see _.findKey + */ + findKey( + predicate?: DictionaryIterator, + thisArg?: any + ): string; + /** * @see _.findKey */ @@ -8988,7 +9005,7 @@ declare module _ { } interface DictionaryIterator { - (value: T, key: string, collection: Dictionary): TResult; + (value: T, key?: string, collection?: Dictionary): TResult; } interface ObjectIterator {