Currently, the typings for pipe() are arranged in such a way that the Source-specific patterns take precedence over the generic consumer, causing pipe(source, consumer) to be typed as Source<unknown> if consumer returns a function. A trivial example:
// x is inferred to be Source<unknown>, but should be `() => number`
let x = pipe(empty, src => () => 42)
However, as far as I can tell, all the Source-specific typings aren't needed, since the actual pipe() implementation is generic and can take any functions, so the typings could just be e.g.:
Currently, the typings for pipe() are arranged in such a way that the Source-specific patterns take precedence over the generic consumer, causing
pipe(source, consumer)
to be typed asSource<unknown>
ifconsumer
returns a function. A trivial example:However, as far as I can tell, all the Source-specific typings aren't needed, since the actual pipe() implementation is generic and can take any functions, so the typings could just be e.g.:
This fully-generic typing is shorter and does not get confused about consumers that return functions, and lets you pipe anything through anything.
Would you like a PR for this?