mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Lodash: zip: add undefined to return values (#23305)
* Lodash: `zip`: add undefined to return values * Lodash: `zip`: correct generic typo * Lodash: `zip`: add undefined to return values for other overloads * Lodash: `zip`: use `` for tests
This commit is contained in:
committed by
Sheetal Nandi
parent
0db2724abb
commit
962a9ec919
Vendored
+16
-16
@@ -8,27 +8,27 @@ declare module "../index" {
|
||||
* @param arrays The arrays to process.
|
||||
* @return Returns the new array of grouped elements.
|
||||
*/
|
||||
zip<T1, T2>(arrays1: List<T1>, arrays2: List<T2>): Array<[T1, T2]>;
|
||||
zip<T1, T2>(arrays1: List<T1>, arrays2: List<T2>): Array<[T1 | undefined, T2 | undefined]>;
|
||||
|
||||
/**
|
||||
* @see _.zip
|
||||
*/
|
||||
zip<T1, T2, T3>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>): Array<[T1, T2, T3]>;
|
||||
zip<T1, T2, T3>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>): Array<[T1 | undefined, T2 | undefined, T3 | undefined]>;
|
||||
|
||||
/**
|
||||
* @see _.zip
|
||||
*/
|
||||
zip<T1, T2, T3, T4>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>, arrays4: List<T4>): Array<[T1, T2, T3, T4]>;
|
||||
zip<T1, T2, T3, T4>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>, arrays4: List<T4>): Array<[T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined]>;
|
||||
|
||||
/**
|
||||
* @see _.zip
|
||||
*/
|
||||
zip<T1, T2, T3, T4, T5>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>, arrays4: List<T4>, arrays5: List<T5>): Array<[T1, T2, T3, T4, T5]>;
|
||||
zip<T1, T2, T3, T4, T5>(arrays1: List<T1>, arrays2: List<T2>, arrays3: List<T3>, arrays4: List<T4>, arrays5: List<T5>): Array<[T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined, T5 | undefined]>;
|
||||
|
||||
/**
|
||||
* @see _.zip
|
||||
*/
|
||||
zip<T>(...arrays: Array<List<T> | null | undefined>): T[][];
|
||||
zip<T>(...arrays: Array<List<T> | null | undefined>): (T | undefined)[][];
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapper<TValue> {
|
||||
@@ -38,7 +38,7 @@ declare module "../index" {
|
||||
zip<T1, T2>(
|
||||
this: LoDashImplicitWrapper<List<T1>>,
|
||||
arrays2: List<T2>,
|
||||
): LoDashImplicitWrapper<Array<[T1, T2]>>;
|
||||
): LoDashImplicitWrapper<Array<[T1 | undefined, T2 | undefined]>>;
|
||||
|
||||
/**
|
||||
* @see _.zip
|
||||
@@ -47,7 +47,7 @@ declare module "../index" {
|
||||
this: LoDashImplicitWrapper<List<T1>>,
|
||||
arrays2: List<T2>,
|
||||
arrays3: List<T3>,
|
||||
): LoDashImplicitWrapper<Array<[T1, T2, T3]>>;
|
||||
): LoDashImplicitWrapper<Array<[T1 | undefined, T2 | undefined, T3 | undefined]>>;
|
||||
|
||||
/**
|
||||
* @see _.zip
|
||||
@@ -57,7 +57,7 @@ declare module "../index" {
|
||||
arrays2: List<T2>,
|
||||
arrays3: List<T3>,
|
||||
arrays4: List<T4>,
|
||||
): LoDashImplicitWrapper<Array<[T1, T2, T3, T4]>>;
|
||||
): LoDashImplicitWrapper<Array<[T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined]>>;
|
||||
|
||||
/**
|
||||
* @see _.zip
|
||||
@@ -68,7 +68,7 @@ declare module "../index" {
|
||||
arrays3: List<T3>,
|
||||
arrays4: List<T4>,
|
||||
arrays5: List<T5>,
|
||||
): LoDashImplicitWrapper<Array<[T1, T2, T3, T4, T5]>>;
|
||||
): LoDashImplicitWrapper<Array<[T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined, T5 | undefined]>>;
|
||||
|
||||
/**
|
||||
* @see _.zip
|
||||
@@ -76,7 +76,7 @@ declare module "../index" {
|
||||
zip<T>(
|
||||
this: LoDashImplicitWrapper<List<T> | null | undefined>,
|
||||
...arrays: Array<List<T> | null | undefined>
|
||||
): LoDashImplicitWrapper<T[][]>;
|
||||
): LoDashImplicitWrapper<Array<Array<T | undefined>>>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<TValue> {
|
||||
@@ -86,7 +86,7 @@ declare module "../index" {
|
||||
zip<T1, T2>(
|
||||
this: LoDashExplicitWrapper<List<T1>>,
|
||||
arrays2: List<T2>,
|
||||
): LoDashExplicitWrapper<Array<[T1, T2]>>;
|
||||
): LoDashExplicitWrapper<Array<[T1 | undefined, T2 | undefined]>>;
|
||||
|
||||
/**
|
||||
* @see _.zip
|
||||
@@ -95,7 +95,7 @@ declare module "../index" {
|
||||
this: LoDashExplicitWrapper<List<T1>>,
|
||||
arrays2: List<T2>,
|
||||
arrays3: List<T3>,
|
||||
): LoDashExplicitWrapper<Array<[T1, T2, T3]>>;
|
||||
): LoDashExplicitWrapper<Array<[T1 | undefined, T2 | undefined, T3 | undefined]>>;
|
||||
|
||||
/**
|
||||
* @see _.zip
|
||||
@@ -105,7 +105,7 @@ declare module "../index" {
|
||||
arrays2: List<T2>,
|
||||
arrays3: List<T3>,
|
||||
arrays4: List<T4>,
|
||||
): LoDashExplicitWrapper<Array<[T1, T2, T3, T4]>>;
|
||||
): LoDashExplicitWrapper<Array<[T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined]>>;
|
||||
|
||||
/**
|
||||
* @see _.zip
|
||||
@@ -116,7 +116,7 @@ declare module "../index" {
|
||||
arrays3: List<T3>,
|
||||
arrays4: List<T4>,
|
||||
arrays5: List<T5>,
|
||||
): LoDashExplicitWrapper<Array<[T1, T2, T3, T4, T5]>>;
|
||||
): LoDashExplicitWrapper<Array<[T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined, T5 | undefined]>>;
|
||||
|
||||
/**
|
||||
* @see _.zip
|
||||
@@ -124,6 +124,6 @@ declare module "../index" {
|
||||
zip<T>(
|
||||
this: LoDashExplicitWrapper<List<T> | null | undefined>,
|
||||
...arrays: Array<List<T> | null | undefined>
|
||||
): LoDashExplicitWrapper<T[][]>;
|
||||
): LoDashExplicitWrapper<Array<Array<T | undefined>>>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3197,43 +3197,52 @@ namespace TestXor {
|
||||
let list: _.List<TResult> | null | undefined = [] as any;
|
||||
|
||||
{
|
||||
let result: TResult[][];
|
||||
// $ExpectType (TResult | undefined)[][]
|
||||
_.zip<TResult>(array);
|
||||
// $ExpectType (TResult | undefined)[][]
|
||||
_.zip<TResult>(array, list);
|
||||
// $ExpectType (TResult | undefined)[][]
|
||||
_.zip<TResult>(array, list, array);
|
||||
|
||||
result = _.zip<TResult>(array);
|
||||
result = _.zip<TResult>(array, list);
|
||||
result = _.zip<TResult>(array, list, array);
|
||||
// $ExpectType (TResult | undefined)[][]
|
||||
_.zip<TResult>(list);
|
||||
// $ExpectType (TResult | undefined)[][]
|
||||
_.zip<TResult>(list, array);
|
||||
// $ExpectType (TResult | undefined)[][]
|
||||
_.zip<TResult>(list, array, list);
|
||||
|
||||
result = _.zip<TResult>(list);
|
||||
result = _.zip<TResult>(list, array);
|
||||
result = _.zip<TResult>(list, array, list);
|
||||
|
||||
result = _.zip(list, array, list, array, list, array);
|
||||
// $ExpectType (TResult | undefined)[][]
|
||||
_.zip(list, array, list, array, list, array);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitArrayWrapper<TResult[]>;
|
||||
// $ExpectType LoDashImplicitWrapper<(TResult | undefined)[][]>
|
||||
_(array).zip<TResult>(list);
|
||||
// $ExpectType LoDashImplicitWrapper<(TResult | undefined)[][]>
|
||||
_(array).zip<TResult>(list, array);
|
||||
|
||||
result = _(array).zip<TResult>(list);
|
||||
result = _(array).zip<TResult>(list, array);
|
||||
|
||||
result = _(list).zip<TResult>(array);
|
||||
result = _(list).zip<TResult>(array, list);
|
||||
// $ExpectType LoDashImplicitWrapper<(TResult | undefined)[][]>
|
||||
_(list).zip<TResult>(array);
|
||||
// $ExpectType LoDashImplicitWrapper<(TResult | undefined)[][]>
|
||||
_(list).zip<TResult>(array, list);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitArrayWrapper<TResult[]>;
|
||||
// $ExpectType LoDashExplicitWrapper<(TResult | undefined)[][]>
|
||||
_(array).chain().zip<TResult>(list);
|
||||
// $ExpectType LoDashExplicitWrapper<(TResult | undefined)[][]>
|
||||
_(array).chain().zip<TResult>(list, array);
|
||||
|
||||
result = _(array).chain().zip<TResult>(list);
|
||||
result = _(array).chain().zip<TResult>(list, array);
|
||||
|
||||
result = _(list).chain().zip<TResult>(array);
|
||||
result = _(list).chain().zip<TResult>(array, list);
|
||||
// $ExpectType LoDashExplicitWrapper<(TResult | undefined)[][]>
|
||||
_(list).chain().zip<TResult>(array);
|
||||
// $ExpectType LoDashExplicitWrapper<(TResult | undefined)[][]>
|
||||
_(list).chain().zip<TResult>(array, list);
|
||||
}
|
||||
|
||||
{
|
||||
_.zip([1, 2], [3, 4]); // $ExpectType [number, number][]
|
||||
_.zip([1, 2], ["a", "b"]); // $ExpectType [number, string][]
|
||||
_.zip([1, 2], ["a", "b"], [true, false]); // $ExpectType [number, string, boolean][]
|
||||
_.zip([1, 2], [3, 4]); // $ExpectType [number | undefined, number | undefined][]
|
||||
_.zip([1, 2], ["a", "b"]); // $ExpectType [number | undefined, string | undefined][]
|
||||
_.zip([1, 2], ["a", "b"], [true, false]); // $ExpectType [number | undefined, string | undefined, boolean | undefined][]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user