diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index c083edd4c..340b13764 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3468,14 +3468,6 @@ result = _(new TestValueIn()).valuesIn().value(); * Utility * ***********/ -// _.attempt -interface TestAttemptFn { - (): TResult; -} -var testAttempFn: TestAttemptFn; -result = _.attempt(testAttempFn); -result = _(testAttempFn).attempt(); - // _.noop result = _.noop(); result = _.noop(1); @@ -3678,6 +3670,24 @@ result = _('fred, barney, & pebbles').words(/[^, ]+/g); * Utility * ***********/ +// _.attempt +module TestAttempt { + let func: (...args: any[]) => {a: string}; + + { + let result: {a: string}|Error; + + result = _.attempt<{a: string}>(func); + result = _(func).attempt<{a: string}>(); + } + + { + let result: _.LoDashExplicitObjectWrapper<{a: string}|Error>; + + result = _(func).chain().attempt<{a: string}>(); + } +} + // _.callback { let result: (...args: any[]) => TResult; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 881124328..5e85a6c28 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9401,6 +9401,7 @@ declare module _ { /** * Attempts to invoke func, returning either the result or the caught error object. Any additional arguments * are provided to func when it’s invoked. + * * @param func The function to attempt. * @return Returns the func result or error object. */ @@ -9414,6 +9415,13 @@ declare module _ { attempt(): TResult|Error; } + interface LoDashExplicitObjectWrapper { + /** + * @see _.attempt + */ + attempt(): LoDashExplicitObjectWrapper; + } + //_.callback interface LoDashStatic { /**