mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-25 11:11:46 +08:00
Merge pull request #6712 from chrootsu/lodash-property
lodash: signatures of the method _.property have been changed
This commit is contained in:
+30
-16
@@ -5722,22 +5722,6 @@ result = <number[]>_.valuesIn<number>(new TestValueIn());
|
||||
result = <number[]>_(new TestValueIn()).valuesIn<number>().value();
|
||||
// → [1, 2, 3]
|
||||
|
||||
/**********
|
||||
* Utility *
|
||||
***********/
|
||||
|
||||
// _.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);
|
||||
|
||||
/**********
|
||||
* String *
|
||||
**********/
|
||||
@@ -6694,6 +6678,36 @@ module TestNoop {
|
||||
}
|
||||
}
|
||||
|
||||
// _.property
|
||||
module TestProperty {
|
||||
interface SampleObject {
|
||||
a: {
|
||||
b: number[];
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
let result: (object: SampleObject) => number;
|
||||
|
||||
result = _.property<SampleObject, number>('a.b[0]');
|
||||
result = _.property<SampleObject, number>(['a', 'b', 0]);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitObjectWrapper<(object: SampleObject) => number>;
|
||||
|
||||
result = _('a.b[0]').property<SampleObject, number>();
|
||||
result = _(['a', 'b', 0]).property<SampleObject, number>();
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitObjectWrapper<(object: SampleObject) => number>;
|
||||
|
||||
result = _('a.b[0]').chain().property<SampleObject, number>();
|
||||
result = _(['a', 'b', 0]).chain().property<SampleObject, number>();
|
||||
}
|
||||
}
|
||||
|
||||
// _.propertyOf
|
||||
module TestPropertyOf {
|
||||
interface SampleObject {
|
||||
|
||||
Vendored
+17
-2
@@ -12121,13 +12121,14 @@ declare module _ {
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* 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;
|
||||
property<TObj, TResult>(path: StringRepresentable|StringRepresentable[]): (obj: TObj) => TResult;
|
||||
}
|
||||
|
||||
interface LoDashImplicitStringWrapper {
|
||||
interface LoDashImplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.property
|
||||
*/
|
||||
@@ -12141,6 +12142,20 @@ declare module _ {
|
||||
property<TObj, TResult>(): LoDashImplicitObjectWrapper<(obj: TObj) => TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.property
|
||||
*/
|
||||
property<TObj, TResult>(): LoDashExplicitObjectWrapper<(obj: TObj) => TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.property
|
||||
*/
|
||||
property<TObj, TResult>(): LoDashExplicitObjectWrapper<(obj: TObj) => TResult>;
|
||||
}
|
||||
|
||||
//_.propertyOf
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user