diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index fa228da4d..d8dd0f317 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -5722,22 +5722,6 @@ result = _.valuesIn(new TestValueIn()); result = _(new TestValueIn()).valuesIn().value(); // → [1, 2, 3] -/********** -* Utility * -***********/ - -// _.property -interface TestPropertyObject { - a: { - b: number; - } -} -var testPropertyObject: TestPropertyObject; -result = _.property('a.b')(testPropertyObject); -result = _.property(['a', 'b'])(testPropertyObject); -result = (_('a.b').property().value())(testPropertyObject); -result = (_(['a', 'b']).property().value())(testPropertyObject); - /********** * String * **********/ @@ -6694,6 +6678,36 @@ module TestNoop { } } +// _.property +module TestProperty { + interface SampleObject { + a: { + b: number[]; + } + } + + { + let result: (object: SampleObject) => number; + + result = _.property('a.b[0]'); + result = _.property(['a', 'b', 0]); + } + + { + let result: _.LoDashImplicitObjectWrapper<(object: SampleObject) => number>; + + result = _('a.b[0]').property(); + result = _(['a', 'b', 0]).property(); + } + + { + let result: _.LoDashExplicitObjectWrapper<(object: SampleObject) => number>; + + result = _('a.b[0]').chain().property(); + result = _(['a', 'b', 0]).chain().property(); + } +} + // _.propertyOf module TestPropertyOf { interface SampleObject { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 347c950c8..8226de52a 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -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(path: string|string[]): (obj: TObj) => TResult; + property(path: StringRepresentable|StringRepresentable[]): (obj: TObj) => TResult; } - interface LoDashImplicitStringWrapper { + interface LoDashImplicitWrapper { /** * @see _.property */ @@ -12141,6 +12142,20 @@ declare module _ { property(): LoDashImplicitObjectWrapper<(obj: TObj) => TResult>; } + interface LoDashExplicitWrapper { + /** + * @see _.property + */ + property(): LoDashExplicitObjectWrapper<(obj: TObj) => TResult>; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.property + */ + property(): LoDashExplicitObjectWrapper<(obj: TObj) => TResult>; + } + //_.propertyOf interface LoDashStatic { /**