Skip to content

scan() definition #3879

Closed
Closed
@Karql

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:

scan

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    TSIssues and PRs related purely to TypeScript issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions