Incorrect type for `zip` function when arrays have different sizes
p2: type enhancement
Consider the call:
```ts
import { zip } from 'es-toolkit';
const result = zip([1, 2, 3], ['a', 'b']);
// [ [ 1, 'a' ], [ 2, 'b' ], [ 3, undefined ] ]
```
If I check the type of `result`, it becomes `[number, string][]`, instead of `[number | undefined, string | undefined][]`. In essence, if the arrays don't have the same size, the resulting entries may include undefined values, but the type of the corresponding entries does not include the `undefined` that is used as a filler.
关闭于 2026-03-19 1 条评论