Description
Hi!
I've just started my journey with rxjs ;)
Reading overview I've gone to scan() documentation.
After some lecture I thought "why seed is type of T|R"
I checked the source code:
https://github.com/ReactiveX/rxjs/blob/6.2.1/src/internal/operators/scan.ts
Ok seed is type T|R in case of use first value of source when is not passed.
But imo this is correct behavior when T == R
When T != R it can case errors like this:
Imo to avoid this seed should be mandatory when T != R.
It imiples on change in definition from:
export function scan<T, R>(accumulator: (acc: R, value: T, index: number) => R, seed?: R): OperatorFunction<T, R>;
to:
export function scan<T, R>(accumulator: (acc: R, value: T, index: number) => R, seed: R): OperatorFunction<T, R>;
What do you think? Should I create PR for this?
Activity