Re:A generically typed pipe function in TypeScript
by cobertos on Monday August 08, 2022 @12:46AM
(#32382452)
Chaining functions _does_ need this though, in current Typescript. The pipe function has to enforce some really complex constraints (inner types between siblings/fn args). There's really no other "correct" way to write this without calling it a day and just doing a generic for different amount of args (<A>, <A, B>, <A, B, C>, etc).
I agree it's complex, but necessary for a utility like this if you want correctness for arbitrary N args
I agree it's complex, but necessary for a utility like this if you want correctness for arbitrary N args