Skip to content
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

fix(scan-operator): Improve typings using newer TS features #4763

Closed

Conversation

cah-kyle-dunn
Copy link

Description:
The scan operator does not properly infer types when the output Observable type differs from the input Observable type (i.e. T != R). This issue was discussed at length a few years back in #2897. That PR was ultimately closed because there were unavoidable limitations due to the minimum supported TypeScript at that time. The current minimum TS version should allow these types to be improved.

Using issue #3150 as an example:

of('0').pipe(
  scan((acc, str) => acc + parseInt(str), 0)
);

The current types cause both acc and str to be inferred as a string type, but acc should be inferred to be a number from the seed value 0, which is what my change fixes.

Related issue (if exists):
#3150

@cah-kyle-dunn
Copy link
Author

Closing in favor of #4598

@coveralls
Copy link

Pull Request Test Coverage Report for Build 8471

  • 2 of 2 (100.0%) changed or added relevant lines in 2 files are covered.
  • 5 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.2%) to 96.842%

Files with Coverage Reduction New Missed Lines %
src/internal/scheduled/scheduleObservable.ts 1 92.31%
src/internal/scheduled/scheduled.ts 1 79.41%
src/internal/scheduled/scheduleIterable.ts 3 89.19%
Totals Coverage Status
Change from base Build 8469: 0.2%
Covered Lines: 5796
Relevant Lines: 5985

💛 - Coveralls

@lock lock bot locked as resolved and limited conversation to collaborators Jun 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants