Skip to content

Commit

Permalink
feat(first): support type guards without casting
Browse files Browse the repository at this point in the history
  • Loading branch information
rob3c committed Nov 7, 2016
1 parent 9058bf6 commit 3aa1988
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/operator/first.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ import { EmptyError } from '../util/EmptyError';
* @owner Observable
*/
/* tslint:disable:max-line-length */
export function first<T>(this: Observable<T>, predicate?: (value: T, index: number, source: Observable<T>) => boolean): Observable<T>;
export function first<T, S extends T>(this: Observable<T>, predicate?: (value: T, index: number, source: Observable<T>) => value is S): Observable<S>;
export function first<T, S extends T>(this: Observable<T>,
predicate?: ((value: T, index: number, source: Observable<T>) => boolean) |
((value: T, index: number, source: Observable<T>) => value is S)): Observable<S>;
export function first<T>(this: Observable<T>, predicate: (value: T, index: number, source: Observable<T>) => boolean, resultSelector: void, defaultValue?: T): Observable<T>;
export function first<T, S extends T>(this: Observable<T>, predicate: (value: T, index: number, source: Observable<T>) => value is S, resultSelector: void, defaultValue?: S): Observable<S>;
export function first<T, S extends T, R>(this: Observable<T>,
predicate: ((value: T, index: number, source: Observable<T>) => boolean) |
((value: T, index: number, source: Observable<T>) => value is S),
resultSelector?: ((value: S, index: number) => R) | void,
defaultValue?: S): Observable<S>;
export function first<T, R>(this: Observable<T>, predicate?: (value: T, index: number, source: Observable<T>) => boolean, resultSelector?: (value: T, index: number) => R, defaultValue?: R): Observable<R>;
/* tslint:disable:max-line-length */
export function first<T, R>(this: Observable<T>, predicate?: (value: T, index: number, source: Observable<T>) => boolean,
Expand Down

0 comments on commit 3aa1988

Please sign in to comment.