From ef8e997e40acbfd1d0137902f3296bff0d54b7cd Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 11 Nov 2015 19:40:33 +0500 Subject: [PATCH] lodash: signatures of the method _.property have been changed --- lodash/lodash-tests.ts | 46 +++++++++++++++++++++++++++--------------- lodash/lodash.d.ts | 19 +++++++++++++++-- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 4c587b57b..5f942acc9 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -5588,22 +5588,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 * **********/ @@ -6560,6 +6544,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 98d8bf55d..f32d69618 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -12014,13 +12014,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 */ @@ -12034,6 +12035,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 { /**