-
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
fix(startWith): accepts N arguments and returns correct type #5247
Conversation
1f565f3
to
0deb14b
Compare
Note to self: look at #5157 when reviewing this. |
ping @cartant |
There was a problem hiding this 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', () => { |
There was a problem hiding this comment.
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
src/internal/operators/startWith.ts
Outdated
*/ | ||
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> { |
There was a problem hiding this comment.
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
0deb14b
to
a6b9ab8
Compare
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