fix lodash's Collection.groupBy return type (#35347)

* fix lodash's Collection.groupBy return type

should be

```ts
Object<Dictionary<T[]>>
// not
Object<Dictionary<T>>
```

* Fix String and update tests
This commit is contained in:
Nathan Shively-Sanders
2019-05-10 11:02:34 -07:00
committed by GitHub
parent 0250e5f778
commit 2194a1ac8b
2 changed files with 16 additions and 16 deletions

View File

@@ -956,13 +956,13 @@ declare module "../index" {
/**
* @see _.groupBy
*/
groupBy(iteratee?: ValueIteratee<string>): Object<Dictionary<string>>;
groupBy(iteratee?: ValueIteratee<string>): Object<Dictionary<string[]>>;
}
interface Collection<T> {
/**
* @see _.groupBy
*/
groupBy(iteratee?: ValueIteratee<T>): Object<Dictionary<T>>;
groupBy(iteratee?: ValueIteratee<T>): Object<Dictionary<T[]>>;
}
interface Object<T> {
/**
@@ -974,7 +974,7 @@ declare module "../index" {
/**
* @see _.groupBy
*/
groupBy(iteratee?: ValueIteratee<string>): ObjectChain<Dictionary<string>>;
groupBy(iteratee?: ValueIteratee<string>): ObjectChain<Dictionary<string[]>>;
}
interface StringNullableChain {
/**
@@ -986,7 +986,7 @@ declare module "../index" {
/**
* @see _.groupBy
*/
groupBy(iteratee?: ValueIteratee<T>): ObjectChain<Dictionary<T>>;
groupBy(iteratee?: ValueIteratee<T>): ObjectChain<Dictionary<T[]>>;
}
interface ObjectChain<T> {
/**

View File

@@ -2480,23 +2480,23 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain<number>
_.groupBy(dictionary, ""); // $ExpectType Dictionary<AbcObject[]>
_.groupBy(dictionary, { a: 42 }); // $ExpectType Dictionary<AbcObject[]>
_("").groupBy(); // $ExpectType Object<Dictionary<string>>
_("").groupBy(stringIterator); // $ExpectType Object<Dictionary<string>>
_(list).groupBy(); // $ExpectType Object<Dictionary<AbcObject>>
_(list).groupBy(valueIterator); // $ExpectType Object<Dictionary<AbcObject>>
_(list).groupBy(""); // $ExpectType Object<Dictionary<AbcObject>>
_(list).groupBy({ a: 42 }); // $ExpectType Object<Dictionary<AbcObject>>
_("").groupBy(); // $ExpectType Object<Dictionary<string[]>>
_("").groupBy(stringIterator); // $ExpectType Object<Dictionary<string[]>>
_(list).groupBy(); // $ExpectType Object<Dictionary<AbcObject[]>>
_(list).groupBy(valueIterator); // $ExpectType Object<Dictionary<AbcObject[]>>
_(list).groupBy(""); // $ExpectType Object<Dictionary<AbcObject[]>>
_(list).groupBy({ a: 42 }); // $ExpectType Object<Dictionary<AbcObject[]>>
_(dictionary).groupBy(); // $ExpectType Object<Dictionary<AbcObject[]>>
_(dictionary).groupBy(valueIterator); // $ExpectType Object<Dictionary<AbcObject[]>>
_(dictionary).groupBy(""); // $ExpectType Object<Dictionary<AbcObject[]>>
_(dictionary).groupBy({ a: 42 }); // $ExpectType Object<Dictionary<AbcObject[]>>
_.chain("").groupBy(); // $ExpectType ObjectChain<Dictionary<string>>
_.chain("").groupBy(stringIterator); // $ExpectType ObjectChain<Dictionary<string>>
_.chain(list).groupBy(); // $ExpectType ObjectChain<Dictionary<AbcObject>>
_.chain(list).groupBy(valueIterator); // $ExpectType ObjectChain<Dictionary<AbcObject>>
_.chain(list).groupBy(""); // $ExpectType ObjectChain<Dictionary<AbcObject>>
_.chain(list).groupBy({ a: 42 }); // $ExpectType ObjectChain<Dictionary<AbcObject>>
_.chain("").groupBy(); // $ExpectType ObjectChain<Dictionary<string[]>>
_.chain("").groupBy(stringIterator); // $ExpectType ObjectChain<Dictionary<string[]>>
_.chain(list).groupBy(); // $ExpectType ObjectChain<Dictionary<AbcObject[]>>
_.chain(list).groupBy(valueIterator); // $ExpectType ObjectChain<Dictionary<AbcObject[]>>
_.chain(list).groupBy(""); // $ExpectType ObjectChain<Dictionary<AbcObject[]>>
_.chain(list).groupBy({ a: 42 }); // $ExpectType ObjectChain<Dictionary<AbcObject[]>>
_.chain(dictionary).groupBy(); // $ExpectType ObjectChain<Dictionary<AbcObject[]>>
_.chain(dictionary).groupBy(valueIterator); // $ExpectType ObjectChain<Dictionary<AbcObject[]>>
_.chain(dictionary).groupBy(""); // $ExpectType ObjectChain<Dictionary<AbcObject[]>>