-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scan() definition #3879
Comments
Requiring users to pass the initial value of their seed seems like the safest route. If not requiring users to provide a value for the first seed the final scan really gets
If not requiring an initial value for the seed |
@bafolts If a seed isn't specified, the initial value passed as the accumulator will be the first received value - i.e. a @Karql Until the tests include proper type expectations - see #3823 - I don't think any changes should be made to the signatures. Unless there is a clear bug. (Even then, there can be unexpected consequences - see #3841.) Also, regarding the |
What is included does match what typescript is using for typing https://github.com/Microsoft/TypeScript/blob/master/src/lib/es5.d.ts#L1090 Something like #3823 would be helpful. |
@cartant I believe we can close this issue please correct me if not and in the best case suggest a way to proceed with this |
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?
The text was updated successfully, but these errors were encountered: