-
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
first operator does not accept default value only signature with null-value predicate #2447
Comments
I tested this with |
|
Yes, I am aware this can be avoided. Still type definition need to be looked into. |
Does something like this look valid? I could create a PR then ... export function first<T, R>(this: Observable<T>, predicate?: (value: T, index: number, source: Observable<T>) => boolean | undefined | null,
resultSelector?: ((value: T, index: number) => R) | void | undefined | null,
defaultValue?: R): Observable<T | R> {
return this.lift(new FirstOperator(predicate, resultSelector, defaultValue, this));
} |
I'm looking at this again after more than a year and I think this should be the expected behavior. Even when the method is defined as optional it shouldn't accept |
This is no longer an issue. |
RxJS version:
latest
Code to reproduce:
Rx.Observable.range(0, 10).first(null, null, true);
Expected behavior:
Actual behavior:
Additional information:
This seems bit weird since default signature allows optional values for predicate / resultselector (
rxjs/src/operator/first.ts
Line 76 in 69d051b
rxjs/spec/operators/first-spec.ts
Line 46 in 69d051b
The text was updated successfully, but these errors were encountered: