From 68b792293c660d3de584f6970efa6b7ea44634e9 Mon Sep 17 00:00:00 2001 From: Robert Raiford Date: Mon, 7 Nov 2016 16:14:38 -0500 Subject: [PATCH 1/4] feat(filter): support type guards without casting --- src/operator/filter.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/operator/filter.ts b/src/operator/filter.ts index 3c13f92e05..50700ccf98 100644 --- a/src/operator/filter.ts +++ b/src/operator/filter.ts @@ -44,9 +44,10 @@ import { TeardownLogic } from '../Subscription'; * @owner Observable */ /* tslint:disable:max-line-length */ -export function filter(this: Observable, predicate: (value: T, index: number) => boolean, thisArg?: any): Observable; -export function filter(this: Observable, predicate: (value: T, index: number) => value is S, thisArg?: any): Observable; -/* tslint:disable:max-line-length */ +export function filter(this: Observable, + predicate: ((value: T, index: number) => boolean) | + ((value: T, index: number) => value is S), + thisArg?: any): Observable; export function filter(this: Observable, predicate: (value: T, index: number) => boolean, thisArg?: any): Observable { return this.lift(new FilterOperator(predicate, thisArg)); From 9058bf677493826835f0b1d406a6945e5e8a0a4e Mon Sep 17 00:00:00 2001 From: Robert Raiford Date: Mon, 7 Nov 2016 16:15:27 -0500 Subject: [PATCH 2/4] feat(find): support type guards without casting --- src/operator/find.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/operator/find.ts b/src/operator/find.ts index a56e172976..3ef646d946 100644 --- a/src/operator/find.ts +++ b/src/operator/find.ts @@ -36,8 +36,10 @@ import { Subscriber } from '../Subscriber'; * @owner Observable */ /* tslint:disable:max-line-length */ -export function find(this: Observable, predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; -export function find(this: Observable, predicate: (value: T, index: number, source: Observable) => value is S, thisArg?: any): Observable; +export function find(this: Observable, + predicate: ((value: T, index: number, source: Observable) => boolean) | + ((value: T, index: number, source: Observable) => value is S), + thisArg?: any): Observable; /* tslint:disable:max-line-length */ export function find(this: Observable, predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable { From 3aa1988d8c60be4851101a26eba53927ff85753a Mon Sep 17 00:00:00 2001 From: Robert Raiford Date: Mon, 7 Nov 2016 16:16:02 -0500 Subject: [PATCH 3/4] feat(first): support type guards without casting --- src/operator/first.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/operator/first.ts b/src/operator/first.ts index 80d442820c..9fb8314ef1 100644 --- a/src/operator/first.ts +++ b/src/operator/first.ts @@ -53,10 +53,15 @@ import { EmptyError } from '../util/EmptyError'; * @owner Observable */ /* tslint:disable:max-line-length */ -export function first(this: Observable, predicate?: (value: T, index: number, source: Observable) => boolean): Observable; -export function first(this: Observable, predicate?: (value: T, index: number, source: Observable) => value is S): Observable; +export function first(this: Observable, + predicate?: ((value: T, index: number, source: Observable) => boolean) | + ((value: T, index: number, source: Observable) => value is S)): Observable; export function first(this: Observable, predicate: (value: T, index: number, source: Observable) => boolean, resultSelector: void, defaultValue?: T): Observable; -export function first(this: Observable, predicate: (value: T, index: number, source: Observable) => value is S, resultSelector: void, defaultValue?: S): Observable; +export function first(this: Observable, + predicate: ((value: T, index: number, source: Observable) => boolean) | + ((value: T, index: number, source: Observable) => value is S), + resultSelector?: ((value: S, index: number) => R) | void, + defaultValue?: S): Observable; export function first(this: Observable, predicate?: (value: T, index: number, source: Observable) => boolean, resultSelector?: (value: T, index: number) => R, defaultValue?: R): Observable; /* tslint:disable:max-line-length */ export function first(this: Observable, predicate?: (value: T, index: number, source: Observable) => boolean, From 07ecd5e7c60be32cb00fc97e941535072be54918 Mon Sep 17 00:00:00 2001 From: Robert Raiford Date: Mon, 7 Nov 2016 16:16:36 -0500 Subject: [PATCH 4/4] feat(last): support type guards without casting --- src/operator/last.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/operator/last.ts b/src/operator/last.ts index e939c18ce3..3a1ea2269f 100644 --- a/src/operator/last.ts +++ b/src/operator/last.ts @@ -21,10 +21,15 @@ import { EmptyError } from '../util/EmptyError'; * @owner Observable */ /* tslint:disable:max-line-length */ -export function last(this: Observable, predicate?: (value: T, index: number, source: Observable) => boolean): Observable; -export function last(this: Observable, predicate?: (value: T, index: number, source: Observable) => value is S): Observable; +export function last(this: Observable, + predicate?: ((value: T, index: number, source: Observable) => boolean) | + ((value: T, index: number, source: Observable) => value is S)): Observable; export function last(this: Observable, predicate: (value: T, index: number, source: Observable) => boolean, resultSelector: void, defaultValue?: T): Observable; -export function last(this: Observable, predicate: (value: T, index: number, source: Observable) => value is S, resultSelector: void, defaultValue?: S): Observable; +export function last(this: Observable, + predicate: ((value: T, index: number, source: Observable) => boolean) | + ((value: T, index: number, source: Observable) => value is S), + resultSelector?: ((value: S, index: number) => R) | void, + defaultValue?: S): Observable; export function last(this: Observable, predicate?: (value: T, index: number, source: Observable) => boolean, resultSelector?: (value: T, index: number) => R, defaultValue?: R): Observable; /* tslint:disable:max-line-length */ export function last(this: Observable, predicate?: (value: T, index: number, source: Observable) => boolean,