Consider the ability to define a zip function with TypeScript that can accept a variable number of parameters:
function genericZip<T extends Array<any>>(...args: T[]): T[][]
Could it be possible to create a zip function with rest parameters and a generic return type?
function zip(...args) {
return args[0].map((_, index) => args.map(row => row[index]));
}
It seems that even with the introduction of new generic rest parameters in Typescript 3.0, such as <T extends any[]>
, they are still insufficient to fully type this particular function.