diff --git a/types/lodash/array/zip.d.ts b/types/lodash/array/zip.d.ts index cc8fa0be88..e6051f64a7 100644 --- a/types/lodash/array/zip.d.ts +++ b/types/lodash/array/zip.d.ts @@ -8,27 +8,27 @@ declare module "../index" { * @param arrays The arrays to process. * @return Returns the new array of grouped elements. */ - zip(arrays1: List, arrays2: List): Array<[T1, T2]>; + zip(arrays1: List, arrays2: List): Array<[T1 | undefined, T2 | undefined]>; /** * @see _.zip */ - zip(arrays1: List, arrays2: List, arrays3: List): Array<[T1, T2, T3]>; + zip(arrays1: List, arrays2: List, arrays3: List): Array<[T1 | undefined, T2 | undefined, T3 | undefined]>; /** * @see _.zip */ - zip(arrays1: List, arrays2: List, arrays3: List, arrays4: List): Array<[T1, T2, T3, T4]>; + zip(arrays1: List, arrays2: List, arrays3: List, arrays4: List): Array<[T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined]>; /** * @see _.zip */ - zip(arrays1: List, arrays2: List, arrays3: List, arrays4: List, arrays5: List): Array<[T1, T2, T3, T4, T5]>; + zip(arrays1: List, arrays2: List, arrays3: List, arrays4: List, arrays5: List): Array<[T1 | undefined, T2 | undefined, T3 | undefined, T4 | undefined, T5 | undefined]>; /** * @see _.zip */ - zip(...arrays: Array | null | undefined>): T[][]; + zip(...arrays: Array | null | undefined>): (T | undefined)[][]; } interface LoDashImplicitWrapper { @@ -38,7 +38,7 @@ declare module "../index" { zip( this: LoDashImplicitWrapper>, arrays2: List, - ): LoDashImplicitWrapper>; + ): LoDashImplicitWrapper>; /** * @see _.zip @@ -47,7 +47,7 @@ declare module "../index" { this: LoDashImplicitWrapper>, arrays2: List, arrays3: List, - ): LoDashImplicitWrapper>; + ): LoDashImplicitWrapper>; /** * @see _.zip @@ -57,7 +57,7 @@ declare module "../index" { arrays2: List, arrays3: List, arrays4: List, - ): LoDashImplicitWrapper>; + ): LoDashImplicitWrapper>; /** * @see _.zip @@ -68,7 +68,7 @@ declare module "../index" { arrays3: List, arrays4: List, arrays5: List, - ): LoDashImplicitWrapper>; + ): LoDashImplicitWrapper>; /** * @see _.zip @@ -76,7 +76,7 @@ declare module "../index" { zip( this: LoDashImplicitWrapper | null | undefined>, ...arrays: Array | null | undefined> - ): LoDashImplicitWrapper; + ): LoDashImplicitWrapper>>; } interface LoDashExplicitWrapper { @@ -86,7 +86,7 @@ declare module "../index" { zip( this: LoDashExplicitWrapper>, arrays2: List, - ): LoDashExplicitWrapper>; + ): LoDashExplicitWrapper>; /** * @see _.zip @@ -95,7 +95,7 @@ declare module "../index" { this: LoDashExplicitWrapper>, arrays2: List, arrays3: List, - ): LoDashExplicitWrapper>; + ): LoDashExplicitWrapper>; /** * @see _.zip @@ -105,7 +105,7 @@ declare module "../index" { arrays2: List, arrays3: List, arrays4: List, - ): LoDashExplicitWrapper>; + ): LoDashExplicitWrapper>; /** * @see _.zip @@ -116,7 +116,7 @@ declare module "../index" { arrays3: List, arrays4: List, arrays5: List, - ): LoDashExplicitWrapper>; + ): LoDashExplicitWrapper>; /** * @see _.zip @@ -124,6 +124,6 @@ declare module "../index" { zip( this: LoDashExplicitWrapper | null | undefined>, ...arrays: Array | null | undefined> - ): LoDashExplicitWrapper; + ): LoDashExplicitWrapper>>; } -} \ No newline at end of file +} diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 9baaa64815..e0c02f2b2d 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -3197,43 +3197,52 @@ namespace TestXor { let list: _.List | null | undefined = [] as any; { - let result: TResult[][]; + // $ExpectType (TResult | undefined)[][] + _.zip(array); + // $ExpectType (TResult | undefined)[][] + _.zip(array, list); + // $ExpectType (TResult | undefined)[][] + _.zip(array, list, array); - result = _.zip(array); - result = _.zip(array, list); - result = _.zip(array, list, array); + // $ExpectType (TResult | undefined)[][] + _.zip(list); + // $ExpectType (TResult | undefined)[][] + _.zip(list, array); + // $ExpectType (TResult | undefined)[][] + _.zip(list, array, list); - result = _.zip(list); - result = _.zip(list, array); - result = _.zip(list, array, list); - - result = _.zip(list, array, list, array, list, array); + // $ExpectType (TResult | undefined)[][] + _.zip(list, array, list, array, list, array); } { - let result: _.LoDashImplicitArrayWrapper; + // $ExpectType LoDashImplicitWrapper<(TResult | undefined)[][]> + _(array).zip(list); + // $ExpectType LoDashImplicitWrapper<(TResult | undefined)[][]> + _(array).zip(list, array); - result = _(array).zip(list); - result = _(array).zip(list, array); - - result = _(list).zip(array); - result = _(list).zip(array, list); + // $ExpectType LoDashImplicitWrapper<(TResult | undefined)[][]> + _(list).zip(array); + // $ExpectType LoDashImplicitWrapper<(TResult | undefined)[][]> + _(list).zip(array, list); } { - let result: _.LoDashExplicitArrayWrapper; + // $ExpectType LoDashExplicitWrapper<(TResult | undefined)[][]> + _(array).chain().zip(list); + // $ExpectType LoDashExplicitWrapper<(TResult | undefined)[][]> + _(array).chain().zip(list, array); - result = _(array).chain().zip(list); - result = _(array).chain().zip(list, array); - - result = _(list).chain().zip(array); - result = _(list).chain().zip(array, list); + // $ExpectType LoDashExplicitWrapper<(TResult | undefined)[][]> + _(list).chain().zip(array); + // $ExpectType LoDashExplicitWrapper<(TResult | undefined)[][]> + _(list).chain().zip(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][] } }