I have one array of functions, data will pass in each function from first to second, from second to third ... to last, it will work like pipe(), I create type that will verify that output of one function will coincide with input of next function
type Hooks<T1, T2, T3, T4, T5, T6, T7, T8, T9> =
[ (e: T1) => T2 ]
| [ (e: T1) => T2, (e: T2) => T3 ]
| [ (e: T1) => T2, (e: T2) => T3, (e: T3) => T4 ]
| [ (e: T1) => T2, (e: T2) => T3, (e: T3) => T4, (e: T4) => T5 ]
| [ (e: T1) => T2, (e: T2) => T3, (e: T3) => T4, (e: T4) => T5, (e: T5) => T6 ]
| [ (e: T1) => T2, (e: T2) => T3, (e: T3) => T4, (e: T4) => T5, (e: T5) => T6, (e: T6) => T7 ]
| [ (e: T1) => T2, (e: T2) => T3, (e: T3) => T4, (e: T4) => T5, (e: T5) => T6, (e: T6) => T7, (e: T7) => T8 ]
| [ (e: T1) => T2, (e: T2) => T3, (e: T3) => T4, (e: T4) => T5, (e: T5) => T6, (e: T6) => T7, (e: T7) => T8, (e: T8) => T9 ];
but problem here is that is required to pass all types in generic
const example: Hooks<number, string, boolean, never, never, never, never, never, never> = [
e => e.toString(),
(e: string) => Boolean(e),
];
Exist method to infer type from function argument ?
Something like
type Hooks =
[ (e: infer T1) => infer T2 ]
| [ (e: T1) => T2, (e: T2) => infer T3 ]
| [ (e: T1) => T2, (e: T2) => T3, (e: T3) => T4 ]; // of course this syntax not valid
or can be just method to send less generic arguments but with saving number of functions in array and ensure that each output will coincide with input of next function