3 ms·
This only applies to TypeScript, but error checking for this pattern from a library is much harder than error checking for native syntax. In order for TypeScri
by Ross-Esmond 4y ago
This only applies to TypeScript, but error checking for this pattern from a library is much harder than error checking for native syntax.
In order for TypeScript to check if the return value of one function has the correct type for the next function, you need to use generics, but generics don't allow for a variable number of generic parameters, so `pipe` would just have to use unknown or have dozens of overloads for each length of pipe usage (within reason).
I know TypeScript is a different, optional language, and I see no reason why they couldn't add the feature without it being in JavaScript, but that's not generally how TypeScript operates. If JavaScript doesn't add it, TypeScript won't. There's also lots of tooling that will type check your JavaScript when available, which will benefit from a simpler model.