From 0854455f2abfe1f49b52d675d7bf94551daf0072 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 31 Aug 2015 06:36:57 +0500 Subject: [PATCH] lodash: changed _.identity() method --- lodash/lodash-tests.ts | 18 ++++++++++++++++-- lodash/lodash.d.ts | 29 +++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5fee08b29e..92a8d299b0 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1644,8 +1644,6 @@ var testAttempFn: TestAttemptFn; result = _.attempt(testAttempFn); result = _(testAttempFn).attempt(); -result = <{ name: string }>_.identity({ 'name': 'moe' }); - _.mixin({ 'capitalize': function (string) { return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); @@ -1895,6 +1893,22 @@ result = <() => boolean>_(true).constant(); result = <() => any[]>_(['a']).constant(); result = <() => {}>_({}).constant<{}>(); +// _.identity +{ + let testIdentityValue: TResult; + let result: TResult; + result = _.identity(testIdentityValue); + result = _(testIdentityValue).identity(); +} +{ + let result: number; + result = _(42).identity(); +} +{ + let result: boolean[]; + result = _([]).identity(); +} + // _.method class TestMethod { a = { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 9815f472b4..a1561d5154 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7993,13 +7993,34 @@ declare module _ { //_.identity interface LoDashStatic { /** - * This method returns the first argument provided to it. - * @param value Any value. - * @return value. - **/ + * This method returns the first argument provided to it. + * @param value Any value. + * @return Returns value. + */ identity(value?: T): T; } + interface LoDashWrapper { + /** + * @see _.identity + */ + identity(): T; + } + + interface LoDashArrayWrapper { + /** + * @see _.identity + */ + identity(): T[]; + } + + interface LoDashObjectWrapper { + /** + * @see _.identity + */ + identity(): T; + } + //_.method interface LoDashStatic { /**