diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index c083edd4c..dfd43b981 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3702,16 +3702,82 @@ result = _('fred, barney, & pebbles').words(/[^, ]+/g); } // _.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<{}>(); +module TestConstant { + { + let result: () => number; + result: _.constant(42); + } + + { + let result: () => string; + result: _.constant('a'); + } + + { + let result: () => boolean; + result: _.constant(true); + } + + { + let result: () => string[]; + result: _.constant(['a']); + } + + { + let result: () => {a: string}; + result: _.constant<{a: string}>({a: 'a'}); + } + + { + let result: _.LoDashImplicitObjectWrapper<() => number>; + result: _(42).constant(); + } + + { + let result: _.LoDashImplicitObjectWrapper<() => string>; + result: _('a').constant(); + } + + { + let result: _.LoDashImplicitObjectWrapper<() => boolean>; + result: _(true).constant(); + } + + { + let result: _.LoDashImplicitObjectWrapper<() => string[]>; + result: _(['a']).constant(); + } + + { + let result: _.LoDashImplicitObjectWrapper<() => {a: string}>; + result: _({a: 'a'}).constant<{a: string}>(); + } + + { + let result: _.LoDashExplicitObjectWrapper<() => number>; + result: _(42).chain().constant(); + } + + { + let result: _.LoDashExplicitObjectWrapper<() => string>; + result: _('a').chain().constant(); + } + + { + let result: _.LoDashExplicitObjectWrapper<() => boolean>; + result: _(true).chain().constant(); + } + + { + let result: _.LoDashExplicitObjectWrapper<() => string[]>; + result: _(['a']).chain().constant(); + } + + { + let result: _.LoDashExplicitObjectWrapper<() => {a: string}>; + result: _({a: 'a'}).chain().constant<{a: string}>(); + } +} // _.identity { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 881124328..a1b7183dc 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9472,6 +9472,31 @@ declare module _ { callback(thisArg?: any): LoDashImplicitObjectWrapper<(...args: any[]) => TResult>; } + //_.constant + interface LoDashStatic { + /** + * 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 LoDashImplicitWrapperBase { + /** + * @see _.constant + */ + constant(): LoDashImplicitObjectWrapper<() => TResult>; + } + + interface LoDashExplicitWrapperBase { + /** + * @see _.constant + */ + constant(): LoDashExplicitObjectWrapper<() => TResult>; + } + //_.identity interface LoDashStatic { /** @@ -9920,23 +9945,6 @@ declare module _ { uniqueId(): string; } - //_.constant - interface LoDashStatic { - /** - * 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 LoDashImplicitWrapperBase { - /** - * @see _.constant - */ - constant(): () => TResult; - } - interface ListIterator { (value: T, index: number, collection: List): TResult; }