Type Alias RecordArgsMapper<R, U, D>

RecordArgsMapper<R, U, D>: {
    [K in keyof R]: ((...args: R[K]) => [] extends U[K]
        ? D
        : U[K])
}

this is analogous to RecordMapper, except now, we deal with variable number of argument parameters instead of just one.
as a compromise, R now has to contain Arrays as its entry values.

Type Parameters

  • R extends Record<any, readonly any[]>
  • U extends {
        [K in keyof R]?: any
    } = {
        [K in keyof R]: unknown
    }
  • D extends any = unknown
type Vec1 = [number]
type Vec2 = [number, number]
type Vec3 = [number, number, number]
const now_i_know_my = { a: [1] as Vec1, b: [2, 2] as Vec2, c: [3, 4, 5] as Vec3, s: ["nein" as string, "mein", "fuhrer"] as const }
const fuhrer_mapper: RecordArgsMapper<typeof now_i_know_my, { s: [string | 9, ...any[]] }, number> = {
a: (v0) => v0 ** 2,
b: (...vs) => vs[0] + vs[1] ** 2,
c: (v0, v1, v2) => v0 ** 0.5 + v1 + v2 ** 2,
s: (arg0, ...args) => [arg0 === "nein" ? 9 : arg0, ...args]
}