mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #5378 from chrootsu/lodash-property
lodash: changed _.property() method
This commit is contained in:
@@ -1506,6 +1506,18 @@ result = <string>_.result(object, 'stuff');
|
||||
var tempObject = {};
|
||||
result = <typeof _>_.runInContext(tempObject);
|
||||
|
||||
// _.property
|
||||
interface TestPropertyObject {
|
||||
a: {
|
||||
b: number;
|
||||
}
|
||||
}
|
||||
var testPropertyObject: TestPropertyObject;
|
||||
result = <number>_.property<TestPropertyObject, number>('a.b')(testPropertyObject);
|
||||
result = <number>_.property<TestPropertyObject, number>(['a', 'b'])(testPropertyObject);
|
||||
result = <number>(_('a.b').property<TestPropertyObject, number>().value())(testPropertyObject);
|
||||
result = <number>(_(['a', 'b']).property<TestPropertyObject, number>().value())(testPropertyObject);
|
||||
|
||||
// _.propertyOf
|
||||
interface TestPropertyOfObject {
|
||||
a: {
|
||||
|
||||
Vendored
+19
-6
@@ -7515,12 +7515,25 @@ declare module _ {
|
||||
//_.property
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* # S
|
||||
* Creates a "_.pluck" style function, which returns the key value of a given object.
|
||||
* @param key (string)
|
||||
* @return the value of that key on the object
|
||||
**/
|
||||
property<T,RT>(key: string): (obj: T) => RT;
|
||||
* Creates a function that returns the property value at path on a given object.
|
||||
* @param path The path of the property to get.
|
||||
* @return Returns the new function.
|
||||
*/
|
||||
property<TObj, TResult>(path: string|string[]): (obj: TObj) => TResult;
|
||||
}
|
||||
|
||||
interface LoDashStringWrapper {
|
||||
/**
|
||||
* @see _.property
|
||||
*/
|
||||
property<TObj, TResult>(): LoDashObjectWrapper<(obj: TObj) => TResult>;
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.property
|
||||
*/
|
||||
property<TObj, TResult>(): LoDashObjectWrapper<(obj: TObj) => TResult>;
|
||||
}
|
||||
|
||||
//_.propertyOf
|
||||
|
||||
Reference in New Issue
Block a user