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(startWith): accepts N arguments and returns correct type #5247

Merged
merged 2 commits into from
Apr 2, 2020

Conversation

benlesh
Copy link
Member

@benlesh benlesh commented Jan 20, 2020

  • Improves documentation a bit
  • Updates type tests

NOTE: Calls with more than 7 arguments that have a Scheduler at the end will return the wrong time. This is consider a corner case and low-risk

BREAKING CHANGE: startWith will return incorrect types when called with more than 7 arguments and a scheduler. Passing scheduler to startWith is deprecated

@cartant
Copy link
Collaborator

cartant commented Jan 22, 2020

Note to self: look at #5157 when reviewing this.

@benlesh
Copy link
Member Author

benlesh commented Jan 29, 2020

ping @cartant

Copy link
Collaborator

@cartant cartant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. A trivial nit.

const r4 = of(a).pipe(startWith(b, c, d, e)); // $ExpectType Observable<A | B | C | D | E>
const r5 = of(a).pipe(startWith(b, c, d, e, f)); // $ExpectType Observable<A | B | C | D | E | F>
const r6 = of(a).pipe(startWith(b, c, d, e, f, g)); // $ExpectType Observable<A | B | C | D | E | F | G>
const r7 = of(a).pipe(startWith(b, c, d, e, f, g, h)); // $ExpectType Observable<A | B | C | D | E | F | G | H>
});

it('should infer correctly with only a scheduler', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: test description is now out-of-date

*/
export function startWith<T, D>(...array: Array<T | SchedulerLike>): OperatorFunction<T, T | D> {
const scheduler = array[array.length - 1] as SchedulerLike;
export function startWith<T, D>(...values: Array<T | SchedulerLike>): OperatorFunction<T, T | D> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that #5157 has been merged, so I'm guessing the change in that PR will be picked up once this is rebased.

- Improves documentation a bit
- Updates type tests

NOTE: Calls with more than 7 arguments that have a Scheduler at the end will return the wrong time. This is consider a corner case and low-risk

BREAKING CHANGE: `startWith` will return incorrect types when called with more than 7 arguments and a scheduler. Passing scheduler to startWith is deprecated
@benlesh benlesh merged commit 150ed8b into ReactiveX:master Apr 2, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2020
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.

2 participants