Initially, I wanted to type redux' mapDispatchToProps-like function and got stuck with handling an array of functions (action creators) as an argument. There is a hacky but working example. I wonder if it can be improved.
The problem is that return type does not preserve types per item, it gets generalized to a union.
Update: the problem is in preserving parameter types per function in the resulting array.
In short, code below should be with no errors:
type F = (...x: any[]) => any
type Wrap<T extends F> = (...x: Parameters<T>) => void
const wrap = (fn: any) => (...a: any) => {fn(...a)}
// currently working solution
// the problem is K being too wide (number | string | symbol) for array index thus silenced
// // @ts-expect-error
// function main<Fs extends readonly F[]>(fs: Fs): {[K in keyof Fs]: Wrap<Fs[K]>}
// TODO: desired solution but not finished: every item in `fs` should be wrapped with `Wrap`
function main<Fs extends readonly F[]>(fs: Fs): [...Fs]
function main(fs: any) {return fs.map(wrap)}
const n = (x: number) => x
const s = (x: string) => x
const fs = main([n, s] as const)
// TEST PARAMETERS TYPES
fs[0](1)
fs[1]('1')
// @ts-expect-error
fs[0]('1')
// @ts-expect-error
fs[1](1)
// TEST RETURN TYPES
const _1: void = fs[0](1)
const _2: void = fs[1]('1')
// @ts-expect-error
const _3: number = fs[0](1)
// @ts-expect-error
const _4: string = fs[1]('1')
P.S: there is an open (as for 25-aug-2020) github issue related to problem of my solution #1, so it is not about variadic tuple types but about keyof ArrayType being too wide for an array index type