diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 13d97526e..f844da157 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3653,14 +3653,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); @@ -3901,6 +3893,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 26d8c5a8e..53d29375d 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9483,6 +9483,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. */ @@ -9496,6 +9497,13 @@ declare module _ { attempt(): TResult|Error; } + interface LoDashExplicitObjectWrapper { + /** + * @see _.attempt + */ + attempt(): LoDashExplicitObjectWrapper; + } + //_.callback interface LoDashStatic { /**