diff --git a/lodash/lodash-3.10-tests.ts b/lodash/lodash-3.10-tests.ts index c3871d381..095fd1c15 100644 --- a/lodash/lodash-3.10-tests.ts +++ b/lodash/lodash-3.10-tests.ts @@ -652,11 +652,36 @@ namespace TestFindLastIndex { namespace TestFirst { let array: TResult[]; let list: _.List; - let result: TResult; - result = _.first(array); - result = _.first(list); - result = _(array).first(); - result = _(list).first(); + + { + let result: string; + + result = _.first('abc'); + result = _('abc').first(); + } + + { + let result: TResult; + + result = _.first(array); + result = _.first(list); + + result = _(array).first(); + result = _(list).first(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _('abc').chain().first(); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _(array).chain().first<_.LoDashExplicitObjectWrapper>(); + result = _(list).chain().first<_.LoDashExplicitObjectWrapper>(); + } } // _.flatten @@ -839,11 +864,36 @@ namespace TestFlattenDeep { namespace TestHead { let array: TResult[]; let list: _.List; - let result: TResult; - result = _.head(array); - result = _.head(list); - result = _(array).head(); - result = _(list).head(); + + { + let result: string; + + result = _.head('abc'); + result = _('abc').head(); + } + + { + let result: TResult; + + result = _.head(array); + result = _.head(list); + + result = _(array).head(); + result = _(list).head(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _('abc').chain().head(); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _(array).chain().head<_.LoDashExplicitObjectWrapper>(); + result = _(list).chain().head<_.LoDashExplicitObjectWrapper>(); + } } // _.indexOf diff --git a/lodash/lodash-3.10.d.ts b/lodash/lodash-3.10.d.ts index f4fcfb1d0..c182bccb6 100644 --- a/lodash/lodash-3.10.d.ts +++ b/lodash/lodash-3.10.d.ts @@ -1166,6 +1166,13 @@ declare module _ { first(array: List): T; } + interface LoDashImplicitWrapper { + /** + * @see _.first + */ + first(): string; + } + interface LoDashImplicitArrayWrapper { /** * @see _.first @@ -1177,7 +1184,28 @@ declare module _ { /** * @see _.first */ - first(): TResult; + first(): T; + } + + interface LoDashExplicitWrapper { + /** + * @see _.first + */ + first(): LoDashExplicitWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.first + */ + first(): T; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.first + */ + first(): T; } interface RecursiveArray extends Array> {} @@ -1309,6 +1337,13 @@ declare module _ { head(array: List): T; } + interface LoDashImplicitWrapper { + /** + * @see _.first + */ + head(): string; + } + interface LoDashImplicitArrayWrapper { /** * @see _.first @@ -1320,7 +1355,28 @@ declare module _ { /** * @see _.first */ - head(): TResult; + head(): T; + } + + interface LoDashExplicitWrapper { + /** + * @see _.first + */ + head(): LoDashExplicitWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.first + */ + head(): T; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.first + */ + head(): T; } //_.indexOf diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index eb74bd0bb..1084247c5 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -811,11 +811,36 @@ namespace TestFindLastIndex { namespace TestFirst { let array: TResult[]; let list: _.List; - let result: TResult; - result = _.first(array); - result = _.first(list); - result = _(array).first(); - result = _(list).first(); + + { + let result: string; + + result = _.first('abc'); + result = _('abc').first(); + } + + { + let result: TResult; + + result = _.first(array); + result = _.first(list); + + result = _(array).first(); + result = _(list).first(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _('abc').chain().first(); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _(array).chain().first<_.LoDashExplicitObjectWrapper>(); + result = _(list).chain().first<_.LoDashExplicitObjectWrapper>(); + } } // _.flatten @@ -998,11 +1023,36 @@ namespace TestFlattenDeep { namespace TestHead { let array: TResult[]; let list: _.List; - let result: TResult; - result = _.head(array); - result = _.head(list); - result = _(array).head(); - result = _(list).head(); + + { + let result: string; + + result = _.head('abc'); + result = _('abc').head(); + } + + { + let result: TResult; + + result = _.head(array); + result = _.head(list); + + result = _(array).head(); + result = _(list).head(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _('abc').chain().head(); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _(array).chain().head<_.LoDashExplicitObjectWrapper>(); + result = _(list).chain().head<_.LoDashExplicitObjectWrapper>(); + } } // _.indexOf diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 28c29ad9d..8ba8b06a5 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1871,12 +1871,19 @@ declare module _ { //_.first interface LoDashStatic { - /** + /** * @see _.head */ first(array: List): T; } + interface LoDashImplicitWrapper { + /** + * @see _.head + */ + first(): string; + } + interface LoDashImplicitArrayWrapper { /** * @see _.head @@ -1888,7 +1895,28 @@ declare module _ { /** * @see _.head */ - first(): TResult; + first(): T; + } + + interface LoDashExplicitWrapper { + /** + * @see _.head + */ + first(): LoDashExplicitWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.head + */ + first(): T; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.head + */ + first(): T; } interface RecursiveArray extends Array> {} @@ -2074,18 +2102,46 @@ declare module _ { head(array: List): T; } + interface LoDashImplicitWrapper { + /** + * @see _.head + */ + head(): string; + } + interface LoDashImplicitArrayWrapper { /** - * @see _.first + * @see _.head */ head(): T; } interface LoDashImplicitObjectWrapper { /** - * @see _.first + * @see _.head */ - head(): TResult; + head(): T; + } + + interface LoDashExplicitWrapper { + /** + * @see _.head + */ + head(): LoDashExplicitWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.head + */ + head(): T; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.head + */ + head(): T; } //_.indexOf