mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-25 11:11:46 +08:00
lodash: improved signatures of the method _.findKey
This commit is contained in:
+28
-13
@@ -2013,28 +2013,43 @@ result = <DefaultsDeepResult>_(TestDefaultsDeepObject).defaultsDeep<DefaultsDeep
|
||||
|
||||
// _.findKey
|
||||
module TestFindKey {
|
||||
let predicateFn: (value: any, key?: string, object?: {}) => 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<string>) => boolean;
|
||||
|
||||
result = _.findKey<string, {a: string;}>({a: ''}, predicateFn);
|
||||
result = _.findKey<string, {a: string;}>({a: ''}, predicateFn, any);
|
||||
|
||||
result = _<{a: string;}>({a: ''}).findKey<string>(predicateFn);
|
||||
result = _<{a: string;}>({a: ''}).findKey<string>(predicateFn, any);
|
||||
}
|
||||
}
|
||||
|
||||
result = <string>_.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) {
|
||||
|
||||
Vendored
+18
-1
@@ -7104,6 +7104,15 @@ declare module _ {
|
||||
* @param thisArg The this binding of predicate.
|
||||
* @return Returns the key of the matched element, else undefined.
|
||||
*/
|
||||
findKey<TValues, TObject>(
|
||||
object: TObject,
|
||||
predicate?: DictionaryIterator<TValues, boolean>,
|
||||
thisArg?: any
|
||||
): string;
|
||||
|
||||
/**
|
||||
* @see _.findKey
|
||||
*/
|
||||
findKey<TObject>(
|
||||
object: TObject,
|
||||
predicate?: ObjectIterator<any, boolean>,
|
||||
@@ -7129,6 +7138,14 @@ declare module _ {
|
||||
}
|
||||
|
||||
interface LoDashObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.findKey
|
||||
*/
|
||||
findKey<TValues>(
|
||||
predicate?: DictionaryIterator<TValues, boolean>,
|
||||
thisArg?: any
|
||||
): string;
|
||||
|
||||
/**
|
||||
* @see _.findKey
|
||||
*/
|
||||
@@ -8988,7 +9005,7 @@ declare module _ {
|
||||
}
|
||||
|
||||
interface DictionaryIterator<T, TResult> {
|
||||
(value: T, key: string, collection: Dictionary<T>): TResult;
|
||||
(value: T, key?: string, collection?: Dictionary<T>): TResult;
|
||||
}
|
||||
|
||||
interface ObjectIterator<T, TResult> {
|
||||
|
||||
Reference in New Issue
Block a user