I am looking to create a custom data type in TypeScript that can store an array of functions, where each function takes the output of the previous one as input. For example, a valid instance of this type would look like:
const pipe: SpecialArray = [
() => string,
(prev:string) => number,
(prev:number) => boolean
];
An invalid array would be:
const pipe: SpecialArray = [
() => string,
(prev:number) => number, // <-- Here number should be string
(prev:number) => boolean
];
Can such a structure be defined in TypeScript?