diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 4c587b57b..a6c2d4719 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3345,11 +3345,37 @@ module TestShuffle { } } -result = _.size([1, 2]); -result = _([1, 2]).size(); -result = _.size({ 'one': 1, 'two': 2, 'three': 3 }); -result = _({ 'one': 1, 'two': 2, 'three': 3 }).size(); -result = _.size('curly'); +// _.size +module TestSize { + type SampleType = {a: string; b: number; c: boolean;}; + + let array: SampleType[]; + let list: _.List; + let dictionary: _.Dictionary; + + { + let result: number; + + result = _.size(array); + result = _.size(list); + result = _.size(dictionary); + result = _.size(''); + + result = _(array).size(); + result = _(list).size(); + result = _(dictionary).size(); + result = _('').size(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(array).chain().size(); + result = _(list).chain().size(); + result = _(dictionary).chain().size(); + result = _('').chain().size(); + } +} // _.some module TestSome { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 98d8bf55d..067efa9b7 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6423,47 +6423,62 @@ declare module _ { //_.size interface LoDashStatic { /** - * Gets the size of the collection by returning collection.length for arrays and array-like - * objects or the number of own enumerable properties for objects. - * @param collection The collection to inspect. - * @return collection.length - **/ - size(collection: Array): number; + * Gets the size of collection by returning its length for array-like values or the number of own enumerable + * properties for objects. + * + * @param collection The collection to inspect. + * @return Returns the size of collection. + */ + size(collection: List|Dictionary): number; /** - * @see _.size - **/ - size(collection: List): number; + * @see _.size + */ + size(collection: string): number; + } + interface LoDashImplicitWrapper { /** - * @see _.size - * @param object The object to inspect - * @return The number of own enumerable properties. - **/ - size(object: T): number; - - /** - * @see _.size - * @param aString The string to inspect - * @return The length of aString - **/ - size(aString: string): number; + * @see _.size + */ + size(): number; } interface LoDashImplicitArrayWrapper { /** * @see _.size - **/ + */ size(): number; } interface LoDashImplicitObjectWrapper { /** * @see _.size - **/ + */ size(): number; } + interface LoDashExplicitWrapper { + /** + * @see _.size + */ + size(): LoDashExplicitWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.size + */ + size(): LoDashExplicitWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.size + */ + size(): LoDashExplicitWrapper; + } + //_.some interface LoDashStatic { /**