Skip to content

Commit

Permalink
feat(last): Observable<T>.last() can take type guard as the predicate…
Browse files Browse the repository at this point in the history
… function
  • Loading branch information
tetsuharuohzeki committed Sep 16, 2016
1 parent f99ca49 commit 76a8a57
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/operator/last.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ export function last<T, R>(predicate?: (value: T, index: number, source: Observa
return this.lift(new LastOperator(predicate, resultSelector, defaultValue, this));
}

// We can cast `T -> R` in it if we pass the result selector.
// Therefore we don't provide the signature which takes both a type guard function
// as the predicate and the result selector.
// (see #1936)
export interface LastSignature<T> {
(predicate?: (value: T, index: number, source: Observable<T>) => boolean): Observable<T>;
<S extends T>(predicate?: (value: T, index: number, source: Observable<T>) => value is S): Observable<S>;
(predicate: (value: T, index: number, source: Observable<T>) => boolean, resultSelector: void, defaultValue?: T): Observable<T>;
<S extends T>(predicate: (value: T, index: number, source: Observable<T>) => value is S, resultSelector: void, defaultValue?: S): Observable<S>;
<R>(predicate?: (value: T, index: number, source: Observable<T>) => boolean, resultSelector?: (value: T, index: number) => R,
defaultValue?: R): Observable<R>;
}
Expand Down

0 comments on commit 76a8a57

Please sign in to comment.