diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 627dda565..d089787a0 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1255,6 +1255,18 @@ result = _.words('fred, barney, & pebbles', /[^, ]+/g); * Utilities * ***********/ +// _.constant +result = <() => number>_.constant(1); +result = <() => string>_.constant('a'); +result = <() => boolean>_.constant(true); +result = <() => any[]>_.constant([]); +result = <() => {}>_.constant<{}>({}); +result = <() => number>_(1).constant(); +result = <() => string>_('a').constant(); +result = <() => boolean>_(true).constant(); +result = <() => any[]>_(['a']).constant(); +result = <() => {}>_({}).constant<{}>(); + result = _.VERSION; result = <_.Support>_.support; result = <_.TemplateSettings>_.templateSettings; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 7bc1df648..c16106ea6 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6626,11 +6626,20 @@ declare module _ { //_.constant interface LoDashStatic { /** - * Creates a function that returns value.. - **/ + * Creates a function that returns value. + * @param value The value to return from the new function. + * @return Returns the new function. + */ constant(value: T): () => T; } + interface LoDashWrapperBase { + /** + * @see _.constant + */ + constant(): () => TResult; + } + //_.create interface LoDashStatic { /**