Skip to content

Commit 133ee1f

Browse files
authored
🤖 Merge PR DefinitelyTyped#74521 Add tuple overloads to lodash unzip to match existing zip overloads by @nathanhleung
Co-authored-by: nathanhleung <nathanhleung@users.noreply.github.com>
1 parent 68c6200 commit 133ee1f

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

‎types/lodash/common/array.d.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,6 +1784,28 @@ declare module "../index" {
17841784
* @param array The array of grouped elements to process.
17851785
* @return Returns the new array of regrouped elements.
17861786
*/
1787+
unzip<T1, T2>(array: Array<[T1, T2]>): [T1[], T2[]];
1788+
/**
1789+
* @see _.unzip
1790+
*/
1791+
unzip<T1, T2, T3>(
1792+
array: Array<[T1, T2, T3]>,
1793+
): [T1[], T2[], T3[]];
1794+
/**
1795+
* @see _.unzip
1796+
*/
1797+
unzip<T1, T2, T3, T4>(
1798+
array: Array<[T1, T2, T3, T4]>,
1799+
): [T1[], T2[], T3[], T4[]];
1800+
/**
1801+
* @see _.unzip
1802+
*/
1803+
unzip<T1, T2, T3, T4, T5>(
1804+
array: Array<[T1, T2, T3, T4, T5]>,
1805+
): [T1[], T2[], T3[], T4[], T5[]];
1806+
/**
1807+
* @see _.unzip
1808+
*/
17871809
unzip<T>(array: T[][] | List<List<T>> | null | undefined): T[][];
17881810
}
17891811
interface Collection<T> {

‎types/lodash/lodash-tests.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,10 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain<number>
14801480
_(list).unzip(); // $ExpectType Collection<AbcObject[]>
14811481
_.chain(list).unzip(); // $ExpectType CollectionChain<AbcObject[]>
14821482
fp.unzip(list); // $ExpectType AbcObject[][]
1483+
1484+
_.unzip([[1, 'a'], [3, 'b'], [5, 'c']]); // $ExpectType [number[], string[]]
1485+
_.unzip([['a', 1, true], ['b', 2, false]]); // $ExpectType [string[], number[], boolean[]]
1486+
_.unzip([[1, undefined], [2, 'a']]); // $ExpectType [number[], (string | undefined)[]]
14831487
}
14841488

14851489
// _.unzipWith

0 commit comments

Comments
 (0)