diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 636efd813..4de0908e7 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1858,43 +1858,89 @@ module TestCollect { let array: number[]; let list: _.List; let dictionary: _.Dictionary; - let listIterator: {(value: number, index: number, collection: _.List): TResult}; - let dictionaryIterator: {(value: number, key: string, collection: _.Dictionary): TResult}; + + let listIterator: (value: number, index: number, collection: _.List) => TResult; + let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => TResult; + { let result: TResult[]; + result = _.collect(array); result = _.collect(array, listIterator); result = _.collect(array, listIterator, any); result = _.collect(array, ''); + result = _.collect(list); result = _.collect(list, listIterator); result = _.collect(list, listIterator, any); result = _.collect(list, ''); + result = _.collect(dictionary); result = _.collect(dictionary, dictionaryIterator); result = _.collect(dictionary, dictionaryIterator, any); result = _.collect(dictionary, ''); - result = _(array).collect().value(); - result = _(array).collect(listIterator).value(); - result = _(array).collect(listIterator, any).value(); - result = _(array).collect('').value(); - result = _(list).collect().value(); - result = _(list).collect(listIterator).value(); - result = _(list).collect(listIterator, any).value(); - result = _(list).collect('').value(); - result = _(dictionary).collect().value(); - result = _(dictionary).collect(dictionaryIterator).value(); - result = _(dictionary).collect(dictionaryIterator, any).value(); - result = _(dictionary).collect('').value(); } + { let result: boolean[]; + result = _.collect(array, {}); result = _.collect(list, {}); result = _.collect(dictionary, {}); - result = _(array).collect<{}>({}).value(); - result = _(list).collect<{}>({}).value(); - result = _(dictionary).collect<{}>({}).value(); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).collect(); + result = _(array).collect(listIterator); + result = _(array).collect(listIterator, any); + result = _(array).collect(''); + + result = _(list).collect(); + result = _(list).collect(listIterator); + result = _(list).collect(listIterator, any); + result = _(list).collect(''); + + result = _(dictionary).collect(); + result = _(dictionary).collect(dictionaryIterator); + result = _(dictionary).collect(dictionaryIterator, any); + result = _(dictionary).collect(''); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).collect<{}>({}); + result = _(list).collect<{}>({}); + result = _(dictionary).collect<{}>({}); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().collect(); + result = _(array).chain().collect(listIterator); + result = _(array).chain().collect(listIterator, any); + result = _(array).chain().collect(''); + + result = _(list).chain().collect(); + result = _(list).chain().collect(listIterator); + result = _(list).chain().collect(listIterator, any); + result = _(list).chain().collect(''); + + result = _(dictionary).chain().collect(); + result = _(dictionary).chain().collect(dictionaryIterator); + result = _(dictionary).chain().collect(dictionaryIterator, any); + result = _(dictionary).chain().collect(''); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().collect<{}>({}); + result = _(list).chain().collect<{}>({}); + result = _(dictionary).chain().collect<{}>({}); } } @@ -2214,32 +2260,68 @@ module TestMap { result = _.map(dictionary, dictionaryIterator); result = _.map(dictionary, dictionaryIterator, any); result = _.map(dictionary, ''); - - result = _(array).map().value(); - result = _(array).map(listIterator).value(); - result = _(array).map(listIterator, any).value(); - result = _(array).map('').value(); - - result = _(list).map().value(); - result = _(list).map(listIterator).value(); - result = _(list).map(listIterator, any).value(); - result = _(list).map('').value(); - - result = _(dictionary).map().value(); - result = _(dictionary).map(dictionaryIterator).value(); - result = _(dictionary).map(dictionaryIterator, any).value(); - result = _(dictionary).map('').value(); } + { let result: boolean[]; result = _.map(array, {}); result = _.map(list, {}); result = _.map(dictionary, {}); + } - result = _(array).map<{}>({}).value(); - result = _(list).map<{}>({}).value(); - result = _(dictionary).map<{}>({}).value(); + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).map(); + result = _(array).map(listIterator); + result = _(array).map(listIterator, any); + result = _(array).map(''); + + result = _(list).map(); + result = _(list).map(listIterator); + result = _(list).map(listIterator, any); + result = _(list).map(''); + + result = _(dictionary).map(); + result = _(dictionary).map(dictionaryIterator); + result = _(dictionary).map(dictionaryIterator, any); + result = _(dictionary).map(''); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).map<{}>({}); + result = _(list).map<{}>({}); + result = _(dictionary).map<{}>({}); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().map(); + result = _(array).chain().map(listIterator); + result = _(array).chain().map(listIterator, any); + result = _(array).chain().map(''); + + result = _(list).chain().map(); + result = _(list).chain().map(listIterator); + result = _(list).chain().map(listIterator, any); + result = _(list).chain().map(''); + + result = _(dictionary).chain().map(); + result = _(dictionary).chain().map(dictionaryIterator); + result = _(dictionary).chain().map(dictionaryIterator, any); + result = _(dictionary).chain().map(''); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().map<{}>({}); + result = _(list).chain().map<{}>({}); + result = _(dictionary).chain().map<{}>({}); } } diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 93d2b53cf..968611892 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -3031,15 +3031,7 @@ declare module _ { * @see _.map */ collect( - collection: List, - iteratee?: string - ): TResult[]; - - /** - * @see _.map - */ - collect( - collection: Dictionary, + collection: List|Dictionary, iteratee?: string ): TResult[]; @@ -3047,15 +3039,7 @@ declare module _ { * @see _.map */ collect( - collection: List, - iteratee?: TObject - ): boolean[]; - - /** - * @see _.map - */ - collect( - collection: Dictionary, + collection: List|Dictionary, iteratee?: TObject ): boolean[]; } @@ -3108,6 +3092,54 @@ declare module _ { ): LoDashImplicitArrayWrapper; } + interface LoDashExplicitArrayWrapper { + /** + * @see _.map + */ + collect( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.map + */ + collect( + iteratee?: string + ): LoDashExplicitArrayWrapper; + + /** + * @see _.map + */ + collect( + iteratee?: TObject + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.map + */ + collect( + iteratee?: ListIterator|DictionaryIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.map + */ + collect( + iteratee?: string + ): LoDashExplicitArrayWrapper; + + /** + * @see _.map + */ + collect( + iteratee?: TObject + ): LoDashExplicitArrayWrapper; + } + //_.contains interface LoDashStatic { /** @@ -4653,15 +4685,7 @@ declare module _ { * @see _.map */ map( - collection: List, - iteratee?: string - ): TResult[]; - - /** - * @see _.map - */ - map( - collection: Dictionary, + collection: List|Dictionary, iteratee?: string ): TResult[]; @@ -4669,15 +4693,7 @@ declare module _ { * @see _.map */ map( - collection: List, - iteratee?: TObject - ): boolean[]; - - /** - * @see _.map - */ - map( - collection: Dictionary, + collection: List|Dictionary, iteratee?: TObject ): boolean[]; } @@ -4730,6 +4746,54 @@ declare module _ { ): LoDashImplicitArrayWrapper; } + interface LoDashExplicitArrayWrapper { + /** + * @see _.map + */ + map( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.map + */ + map( + iteratee?: string + ): LoDashExplicitArrayWrapper; + + /** + * @see _.map + */ + map( + iteratee?: TObject + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.map + */ + map( + iteratee?: ListIterator|DictionaryIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.map + */ + map( + iteratee?: string + ): LoDashExplicitArrayWrapper; + + /** + * @see _.map + */ + map( + iteratee?: TObject + ): LoDashExplicitArrayWrapper; + } + //_.pluck interface LoDashStatic { /**