How do you define an OperatorPipeline
type in TypeScript that takes zero or more RxJS operators and without using any
and or a fixed number of overloads, can match:
- the pipeline input to the input of the first operator function
- the output of each operator with the input of the subsequent one
- the output of the last operator function to the pipeline output
This is the idea, but TS doesn’t appear to like the way infer is used:
type OperatorPipeline<I, O> =
| [ OperatorFunction<I, O> ]
| [ OperatorFunction<I, infer T>, ...OperatorPipeline<T, O> ]
;
const createPipeline = <I, O>(target: Subscriber<O>, ...pipeline: OperatorPipeline<I, O>) => void;