ARTICLE AD BOX
Is it possible to create a functions that can apply multiple Functions while preserving the type information?
// example const add1 = (n: number) => n + 1; const makeArray = <T>(t: T) => [t]; const getArrLength = (arr: any[]) => arr.length; const makeString = (n: number) => n.toString(); // bad chain typeError (now or at invokation) const chainBad = makeChain(makeArray, add1, getArrLength, makeString); // Good Chain goes from number => string const chain = makeChain(add1, makeArray, getArrLength, makeString); chain('1'); //type error var res1: number = chain(1); //type error var res2: string = chain(1); // good