From 0627845f6e87d76e1c770c8e37d3b3ddcbba5224 Mon Sep 17 00:00:00 2001 From: Jason Aden Date: Tue, 3 Oct 2017 17:37:19 -0700 Subject: [PATCH] refactor: cast types so library works with TS 2.4x and 2.5x --- src/observable/ConnectableObservable.ts | 2 +- src/observable/FromEventObservable.ts | 4 ++-- src/observable/GenerateObservable.ts | 4 ++-- src/observable/concat.ts | 2 +- src/observable/dom/AjaxObservable.ts | 2 +- src/operator/auditTime.ts | 2 +- src/operator/buffer.ts | 2 +- src/operator/bufferCount.ts | 2 +- src/operator/bufferTime.ts | 2 +- src/operator/bufferToggle.ts | 2 +- src/operator/bufferWhen.ts | 2 +- src/operator/debounceTime.ts | 2 +- src/operator/dematerialize.ts | 2 +- src/operator/do.ts | 2 +- src/operator/exhaust.ts | 2 +- src/operator/finally.ts | 2 +- src/operator/ignoreElements.ts | 2 +- src/operator/materialize.ts | 2 +- src/operator/merge.ts | 2 +- src/operator/mergeAll.ts | 4 ++-- src/operator/mergeMap.ts | 2 +- src/operator/mergeMapTo.ts | 2 +- src/operator/observeOn.ts | 2 +- src/operator/pairwise.ts | 2 +- src/operator/pluck.ts | 2 +- src/operator/publishReplay.ts | 2 +- src/operator/repeat.ts | 2 +- src/operator/repeatWhen.ts | 2 +- src/operator/retry.ts | 2 +- src/operator/retryWhen.ts | 2 +- src/operator/sample.ts | 2 +- src/operator/sampleTime.ts | 2 +- src/operator/scan.ts | 2 +- src/operator/share.ts | 2 +- src/operator/shareReplay.ts | 2 +- src/operator/skip.ts | 2 +- src/operator/skipLast.ts | 2 +- src/operator/skipUntil.ts | 2 +- src/operator/subscribeOn.ts | 2 +- src/operator/switch.ts | 2 +- src/operator/take.ts | 2 +- src/operator/takeLast.ts | 2 +- src/operator/takeUntil.ts | 2 +- src/operator/throttleTime.ts | 2 +- src/operator/timeInterval.ts | 2 +- src/operator/timeout.ts | 2 +- src/operator/timestamp.ts | 2 +- src/operator/toArray.ts | 2 +- src/operator/toPromise.ts | 2 +- src/operator/window.ts | 2 +- src/operator/windowCount.ts | 2 +- src/operator/windowTime.ts | 2 +- src/operator/windowToggle.ts | 2 +- src/operator/windowWhen.ts | 2 +- src/operators/catchError.ts | 2 +- src/operators/concat.ts | 4 +--- src/operators/defaultIfEmpty.ts | 4 +--- src/operators/merge.ts | 2 +- src/operators/mergeAll.ts | 3 ++- src/operators/partition.ts | 2 +- src/operators/reduce.ts | 2 +- src/operators/share.ts | 2 +- src/operators/shareReplay.ts | 2 +- 63 files changed, 67 insertions(+), 70 deletions(-) diff --git a/src/observable/ConnectableObservable.ts b/src/observable/ConnectableObservable.ts index ee570f2dcc..0179101499 100644 --- a/src/observable/ConnectableObservable.ts +++ b/src/observable/ConnectableObservable.ts @@ -50,7 +50,7 @@ export class ConnectableObservable extends Observable { } refCount(): Observable { - return higherOrderRefCount()(this); + return higherOrderRefCount()(this) as Observable; } } diff --git a/src/observable/FromEventObservable.ts b/src/observable/FromEventObservable.ts index c8596ac9dd..46ef360efd 100644 --- a/src/observable/FromEventObservable.ts +++ b/src/observable/FromEventObservable.ts @@ -101,13 +101,13 @@ export class FromEventObservable extends Observable { */ static create(target: EventTargetLike, eventName: string, - options?: EventListenerOptions, + options?: EventListenerOptions | SelectorMethodSignature, selector?: SelectorMethodSignature): Observable { if (isFunction(options)) { selector = options; options = undefined; } - return new FromEventObservable(target, eventName, selector, options); + return new FromEventObservable(target, eventName, selector, options as EventListenerOptions | undefined); } constructor(private sourceObj: EventTargetLike, diff --git a/src/observable/GenerateObservable.ts b/src/observable/GenerateObservable.ts index 3db21cb8a8..8700a701dd 100644 --- a/src/observable/GenerateObservable.ts +++ b/src/observable/GenerateObservable.ts @@ -179,7 +179,7 @@ export class GenerateObservable extends Observable { (>initialStateOrOptions).initialState, (>initialStateOrOptions).condition, (>initialStateOrOptions).iterate, - (>initialStateOrOptions).resultSelector || selfSelector, + (>initialStateOrOptions).resultSelector || selfSelector as ResultFunc, (>initialStateOrOptions).scheduler); } @@ -188,7 +188,7 @@ export class GenerateObservable extends Observable { initialStateOrOptions, condition, iterate, - selfSelector, + selfSelector as ResultFunc, resultSelectorOrObservable); } diff --git a/src/observable/concat.ts b/src/observable/concat.ts index 556a285da5..b24e3ee971 100644 --- a/src/observable/concat.ts +++ b/src/observable/concat.ts @@ -112,5 +112,5 @@ export function concat(...observables: Array | ISched if (observables.length === 1 || (observables.length === 2 && isScheduler(observables[1]))) { return from(observables[0]); } - return concatAll()(of(...observables)); + return concatAll()(of(...observables)) as Observable; } diff --git a/src/observable/dom/AjaxObservable.ts b/src/observable/dom/AjaxObservable.ts index e820e4521b..7bbf00903c 100644 --- a/src/observable/dom/AjaxObservable.ts +++ b/src/observable/dom/AjaxObservable.ts @@ -255,7 +255,7 @@ export class AjaxSubscriber extends Subscriber { // timeout, responseType and withCredentials can be set once the XHR is open if (async) { xhr.timeout = request.timeout; - xhr.responseType = request.responseType; + xhr.responseType = request.responseType as any; } if ('withCredentials' in xhr) { diff --git a/src/operator/auditTime.ts b/src/operator/auditTime.ts index aa1fa0cead..fb854c6b90 100644 --- a/src/operator/auditTime.ts +++ b/src/operator/auditTime.ts @@ -46,5 +46,5 @@ import { auditTime as higherOrder } from '../operators/auditTime'; * @owner Observable */ export function auditTime(this: Observable, duration: number, scheduler: IScheduler = async): Observable { - return higherOrder(duration, scheduler)(this); + return higherOrder(duration, scheduler)(this) as Observable; } \ No newline at end of file diff --git a/src/operator/buffer.ts b/src/operator/buffer.ts index 4b17b0d847..a79078f402 100644 --- a/src/operator/buffer.ts +++ b/src/operator/buffer.ts @@ -35,5 +35,5 @@ import { buffer as higherOrder } from '../operators/buffer'; * @owner Observable */ export function buffer(this: Observable, closingNotifier: Observable): Observable { - return higherOrder(closingNotifier)(this); + return higherOrder(closingNotifier)(this) as Observable; } diff --git a/src/operator/bufferCount.ts b/src/operator/bufferCount.ts index fd2f759769..321ff4a19c 100644 --- a/src/operator/bufferCount.ts +++ b/src/operator/bufferCount.ts @@ -44,5 +44,5 @@ import { bufferCount as higherOrder } from '../operators/bufferCount'; * @owner Observable */ export function bufferCount(this: Observable, bufferSize: number, startBufferEvery: number = null): Observable { - return higherOrder(bufferSize, startBufferEvery)(this); + return higherOrder(bufferSize, startBufferEvery)(this) as Observable; } diff --git a/src/operator/bufferTime.ts b/src/operator/bufferTime.ts index 783afe3634..d851347929 100644 --- a/src/operator/bufferTime.ts +++ b/src/operator/bufferTime.ts @@ -72,5 +72,5 @@ export function bufferTime(this: Observable, bufferTimeSpan: number): Obse maxBufferSize = arguments[2]; } - return higherOrder(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler)(this); + return higherOrder(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler)(this) as Observable; } diff --git a/src/operator/bufferToggle.ts b/src/operator/bufferToggle.ts index d0d956306b..6c8824a44d 100644 --- a/src/operator/bufferToggle.ts +++ b/src/operator/bufferToggle.ts @@ -42,5 +42,5 @@ import { bufferToggle as higherOrder } from '../operators/bufferToggle'; */ export function bufferToggle(this: Observable, openings: SubscribableOrPromise, closingSelector: (value: O) => SubscribableOrPromise): Observable { - return higherOrder(openings, closingSelector)(this); + return higherOrder(openings, closingSelector)(this) as Observable; } diff --git a/src/operator/bufferWhen.ts b/src/operator/bufferWhen.ts index 803b848bf3..8d6968d878 100644 --- a/src/operator/bufferWhen.ts +++ b/src/operator/bufferWhen.ts @@ -36,5 +36,5 @@ import { bufferWhen as higherOrder } from '../operators/bufferWhen'; * @owner Observable */ export function bufferWhen(this: Observable, closingSelector: () => Observable): Observable { - return higherOrder(closingSelector)(this); + return higherOrder(closingSelector)(this) as Observable; } diff --git a/src/operator/debounceTime.ts b/src/operator/debounceTime.ts index 2be4e661ab..716368baac 100644 --- a/src/operator/debounceTime.ts +++ b/src/operator/debounceTime.ts @@ -51,5 +51,5 @@ import { debounceTime as higherOrder } from '../operators/debounceTime'; * @owner Observable */ export function debounceTime(this: Observable, dueTime: number, scheduler: IScheduler = async): Observable { - return higherOrder(dueTime, scheduler)(this); + return higherOrder(dueTime, scheduler)(this) as Observable; } diff --git a/src/operator/dematerialize.ts b/src/operator/dematerialize.ts index fe9dfe2976..5ceac36e05 100644 --- a/src/operator/dematerialize.ts +++ b/src/operator/dematerialize.ts @@ -44,5 +44,5 @@ import { dematerialize as higherOrder } from '../operators/dematerialize'; * @owner Observable */ export function dematerialize(this: Observable>): Observable { - return higherOrder()(this); + return higherOrder()(this) as Observable; } diff --git a/src/operator/do.ts b/src/operator/do.ts index e6df825805..ed398997f4 100644 --- a/src/operator/do.ts +++ b/src/operator/do.ts @@ -54,5 +54,5 @@ export function _do(this: Observable, observer: PartialObserver): Obser export function _do(this: Observable, nextOrObserver?: PartialObserver | ((x: T) => void), error?: (e: any) => void, complete?: () => void): Observable { - return higherOrder(nextOrObserver, error, complete)(this); + return higherOrder(nextOrObserver, error, complete)(this) as Observable; } diff --git a/src/operator/exhaust.ts b/src/operator/exhaust.ts index 3b0f54484a..004cc605e4 100644 --- a/src/operator/exhaust.ts +++ b/src/operator/exhaust.ts @@ -38,5 +38,5 @@ import { exhaust as higherOrder } from '../operators/exhaust'; * @owner Observable */ export function exhaust(this: Observable): Observable { - return higherOrder()(this); + return higherOrder()(this) as Observable; } diff --git a/src/operator/finally.ts b/src/operator/finally.ts index de0386a595..a640f4f490 100644 --- a/src/operator/finally.ts +++ b/src/operator/finally.ts @@ -11,5 +11,5 @@ import { finalize } from '../operators/finalize'; * @owner Observable */ export function _finally(this: Observable, callback: () => void): Observable { - return finalize(callback)(this); + return finalize(callback)(this) as Observable; } diff --git a/src/operator/ignoreElements.ts b/src/operator/ignoreElements.ts index 25f12506e4..8b8794d070 100644 --- a/src/operator/ignoreElements.ts +++ b/src/operator/ignoreElements.ts @@ -12,5 +12,5 @@ import { ignoreElements as higherOrder } from '../operators/ignoreElements'; * @owner Observable */ export function ignoreElements(this: Observable): Observable { - return higherOrder()(this); + return higherOrder()(this) as Observable; }; diff --git a/src/operator/materialize.ts b/src/operator/materialize.ts index cc7a230fc6..61cbfd800e 100644 --- a/src/operator/materialize.ts +++ b/src/operator/materialize.ts @@ -48,5 +48,5 @@ import { materialize as higherOrder } from '../operators/materialize'; * @owner Observable */ export function materialize(this: Observable): Observable> { - return higherOrder()(this); + return higherOrder()(this) as Observable>; } diff --git a/src/operator/merge.ts b/src/operator/merge.ts index 60013274ea..b04f44e820 100644 --- a/src/operator/merge.ts +++ b/src/operator/merge.ts @@ -68,5 +68,5 @@ export function merge(this: Observable, ...observables: Array(this: Observable, ...observables: Array | IScheduler | number>): Observable { - return higherOrder(...observables)(this); + return higherOrder(...observables)(this) as Observable; } diff --git a/src/operator/mergeAll.ts b/src/operator/mergeAll.ts index fa540c974d..ed62d39e33 100644 --- a/src/operator/mergeAll.ts +++ b/src/operator/mergeAll.ts @@ -49,6 +49,6 @@ export function mergeAll(this: Observable, concurrent?: number): Subscr * @method mergeAll * @owner Observable */ -export function mergeAll(this: Observable, concurrent: number = Number.POSITIVE_INFINITY): T { - return higherOrder(concurrent)(this); +export function mergeAll(this: Observable, concurrent: number = Number.POSITIVE_INFINITY): Observable { + return higherOrder(concurrent)(this) as Observable; } diff --git a/src/operator/mergeMap.ts b/src/operator/mergeMap.ts index 9c7b426ade..68b9044b7e 100644 --- a/src/operator/mergeMap.ts +++ b/src/operator/mergeMap.ts @@ -67,5 +67,5 @@ export function mergeMap(this: Observable, project: (value: T, index export function mergeMap(this: Observable, project: (value: T, index: number) => ObservableInput, resultSelector?: ((outerValue: T, innerValue: I, outerIndex: number, innerIndex: number) => R) | number, concurrent: number = Number.POSITIVE_INFINITY): Observable { - return higherOrderMergeMap(project, resultSelector, concurrent)(this); + return higherOrderMergeMap(project, resultSelector, concurrent)(this) as Observable; } diff --git a/src/operator/mergeMapTo.ts b/src/operator/mergeMapTo.ts index 150153eca5..037ffe2b0c 100644 --- a/src/operator/mergeMapTo.ts +++ b/src/operator/mergeMapTo.ts @@ -52,5 +52,5 @@ export function mergeMapTo(this: Observable, observable: ObservableI export function mergeMapTo(this: Observable, innerObservable: Observable, resultSelector?: ((outerValue: T, innerValue: I, outerIndex: number, innerIndex: number) => R) | number, concurrent: number = Number.POSITIVE_INFINITY): Observable { - return higherOrder(innerObservable, resultSelector as any, concurrent)(this); + return higherOrder(innerObservable, resultSelector as any, concurrent)(this) as Observable; } diff --git a/src/operator/observeOn.ts b/src/operator/observeOn.ts index 6c0f946698..fbb7a8bb74 100644 --- a/src/operator/observeOn.ts +++ b/src/operator/observeOn.ts @@ -49,5 +49,5 @@ import { observeOn as higherOrder } from '../operators/observeOn'; * @owner Observable */ export function observeOn(this: Observable, scheduler: IScheduler, delay: number = 0): Observable { - return higherOrder(scheduler, delay)(this); + return higherOrder(scheduler, delay)(this) as Observable; } diff --git a/src/operator/pairwise.ts b/src/operator/pairwise.ts index e17d8db403..0c6cc7647e 100644 --- a/src/operator/pairwise.ts +++ b/src/operator/pairwise.ts @@ -37,5 +37,5 @@ import { pairwise as higherOrder } from '../operators/pairwise'; * @owner Observable */ export function pairwise(this: Observable): Observable<[T, T]> { - return higherOrder()(this); + return higherOrder()(this) as Observable<[T, T]>; } diff --git a/src/operator/pluck.ts b/src/operator/pluck.ts index 57d2bb26be..5b22ae5fc2 100644 --- a/src/operator/pluck.ts +++ b/src/operator/pluck.ts @@ -28,5 +28,5 @@ import { pluck as higherOrder } from '../operators/pluck'; * @owner Observable */ export function pluck(this: Observable, ...properties: string[]): Observable { - return higherOrder(...properties)(this); + return higherOrder(...properties)(this) as Observable; } diff --git a/src/operator/publishReplay.ts b/src/operator/publishReplay.ts index e5c81d893b..c8cd566a58 100644 --- a/src/operator/publishReplay.ts +++ b/src/operator/publishReplay.ts @@ -14,5 +14,5 @@ import { publishReplay as higherOrder } from '../operators/publishReplay'; export function publishReplay(this: Observable, bufferSize: number = Number.POSITIVE_INFINITY, windowTime: number = Number.POSITIVE_INFINITY, scheduler?: IScheduler): ConnectableObservable { - return higherOrder(bufferSize, windowTime, scheduler)(this); + return higherOrder(bufferSize, windowTime, scheduler)(this) as ConnectableObservable; } diff --git a/src/operator/repeat.ts b/src/operator/repeat.ts index 5fd52e5e0a..c027770cbb 100644 --- a/src/operator/repeat.ts +++ b/src/operator/repeat.ts @@ -15,5 +15,5 @@ import { repeat as higherOrder } from '../operators/repeat'; * @owner Observable */ export function repeat(this: Observable, count: number = -1): Observable { - return higherOrder(count)(this); + return higherOrder(count)(this) as Observable; } diff --git a/src/operator/repeatWhen.ts b/src/operator/repeatWhen.ts index 0731ec23e4..0e6da78026 100644 --- a/src/operator/repeatWhen.ts +++ b/src/operator/repeatWhen.ts @@ -16,5 +16,5 @@ import { repeatWhen as higherOrder } from '../operators/repeatWhen'; * @owner Observable */ export function repeatWhen(this: Observable, notifier: (notifications: Observable) => Observable): Observable { - return higherOrder(notifier)(this); + return higherOrder(notifier)(this) as Observable; } diff --git a/src/operator/retry.ts b/src/operator/retry.ts index 3de682756c..1580f2b146 100644 --- a/src/operator/retry.ts +++ b/src/operator/retry.ts @@ -18,5 +18,5 @@ import { retry as higherOrder } from '../operators/retry'; * @owner Observable */ export function retry(this: Observable, count: number = -1): Observable { - return higherOrder(count)(this); + return higherOrder(count)(this) as Observable; } diff --git a/src/operator/retryWhen.ts b/src/operator/retryWhen.ts index 6d83344789..383a492272 100644 --- a/src/operator/retryWhen.ts +++ b/src/operator/retryWhen.ts @@ -15,5 +15,5 @@ import { retryWhen as higherOrder } from '../operators/retryWhen'; * @owner Observable */ export function retryWhen(this: Observable, notifier: (errors: Observable) => Observable): Observable { - return higherOrder(notifier)(this); + return higherOrder(notifier)(this) as Observable; } diff --git a/src/operator/sample.ts b/src/operator/sample.ts index a9cef87335..80fec74820 100644 --- a/src/operator/sample.ts +++ b/src/operator/sample.ts @@ -36,5 +36,5 @@ import { sample as higherOrder } from '../operators/sample'; * @owner Observable */ export function sample(this: Observable, notifier: Observable): Observable { - return higherOrder(notifier)(this); + return higherOrder(notifier)(this) as Observable; } diff --git a/src/operator/sampleTime.ts b/src/operator/sampleTime.ts index 0b4e62874a..679c2467b8 100644 --- a/src/operator/sampleTime.ts +++ b/src/operator/sampleTime.ts @@ -40,5 +40,5 @@ import { sampleTime as higherOrder } from '../operators/sampleTime'; * @owner Observable */ export function sampleTime(this: Observable, period: number, scheduler: IScheduler = async): Observable { - return higherOrder(period, scheduler)(this); + return higherOrder(period, scheduler)(this) as Observable; } diff --git a/src/operator/scan.ts b/src/operator/scan.ts index f2b16948a7..ea8cbb90cc 100644 --- a/src/operator/scan.ts +++ b/src/operator/scan.ts @@ -47,7 +47,7 @@ export function scan(this: Observable, accumulator: (acc: R, value: T, */ export function scan(this: Observable, accumulator: (acc: R, value: T, index: number) => R, seed?: T | R): Observable { if (arguments.length >= 2) { - return higherOrderScan(accumulator, seed)(this); + return higherOrderScan(accumulator, seed)(this) as Observable; } return higherOrderScan(accumulator)(this); } diff --git a/src/operator/share.ts b/src/operator/share.ts index 6dc98b0b5e..9998c568c4 100644 --- a/src/operator/share.ts +++ b/src/operator/share.ts @@ -18,5 +18,5 @@ import { share as higherOrder } from '../operators/share'; * @owner Observable */ export function share(this: Observable): Observable { - return higherOrder()(this); + return higherOrder()(this) as Observable; }; diff --git a/src/operator/shareReplay.ts b/src/operator/shareReplay.ts index 21d73e3cec..2efe0e9573 100644 --- a/src/operator/shareReplay.ts +++ b/src/operator/shareReplay.ts @@ -8,5 +8,5 @@ import { shareReplay as higherOrder } from '../operators/shareReplay'; */ export function shareReplay(this: Observable, bufferSize?: number, windowTime?: number, scheduler?: IScheduler): Observable { - return higherOrder(bufferSize, windowTime, scheduler)(this); + return higherOrder(bufferSize, windowTime, scheduler)(this) as Observable; }; \ No newline at end of file diff --git a/src/operator/skip.ts b/src/operator/skip.ts index 9344370cec..0066656989 100644 --- a/src/operator/skip.ts +++ b/src/operator/skip.ts @@ -13,5 +13,5 @@ import { skip as higherOrder } from '../operators/skip'; * @owner Observable */ export function skip(this: Observable, count: number): Observable { - return higherOrder(count)(this); + return higherOrder(count)(this) as Observable; } diff --git a/src/operator/skipLast.ts b/src/operator/skipLast.ts index 078cb66679..f63865ea75 100644 --- a/src/operator/skipLast.ts +++ b/src/operator/skipLast.ts @@ -34,5 +34,5 @@ import { skipLast as higherOrder } from '../operators/skipLast'; * @owner Observable */ export function skipLast(this: Observable, count: number): Observable { - return higherOrder(count)(this); + return higherOrder(count)(this) as Observable; } diff --git a/src/operator/skipUntil.ts b/src/operator/skipUntil.ts index ea6c2dad6f..3eb35daf6f 100644 --- a/src/operator/skipUntil.ts +++ b/src/operator/skipUntil.ts @@ -14,5 +14,5 @@ import { skipUntil as higherOrder } from '../operators/skipUntil'; * @owner Observable */ export function skipUntil(this: Observable, notifier: Observable): Observable { - return higherOrder(notifier)(this); + return higherOrder(notifier)(this) as Observable; } diff --git a/src/operator/subscribeOn.ts b/src/operator/subscribeOn.ts index 8e8683c07d..75407a1c3e 100644 --- a/src/operator/subscribeOn.ts +++ b/src/operator/subscribeOn.ts @@ -15,5 +15,5 @@ import { subscribeOn as higherOrder } from '../operators/subscribeOn'; * @owner Observable */ export function subscribeOn(this: Observable, scheduler: IScheduler, delay: number = 0): Observable { - return higherOrder(scheduler, delay)(this); + return higherOrder(scheduler, delay)(this) as Observable; } diff --git a/src/operator/switch.ts b/src/operator/switch.ts index e78b0f1a81..457ad6c18a 100644 --- a/src/operator/switch.ts +++ b/src/operator/switch.ts @@ -44,5 +44,5 @@ import { switchAll as higherOrder } from '../operators/switchAll'; * @owner Observable */ export function _switch(this: Observable>): Observable { - return higherOrder()(this); + return higherOrder()(this) as Observable; } diff --git a/src/operator/take.ts b/src/operator/take.ts index c622c55713..47f0da5bdd 100644 --- a/src/operator/take.ts +++ b/src/operator/take.ts @@ -35,5 +35,5 @@ import { take as higherOrder } from '../operators/take'; * @owner Observable */ export function take(this: Observable, count: number): Observable { - return higherOrder(count)(this); + return higherOrder(count)(this) as Observable; } diff --git a/src/operator/takeLast.ts b/src/operator/takeLast.ts index 9bec7b6999..cb817832b4 100644 --- a/src/operator/takeLast.ts +++ b/src/operator/takeLast.ts @@ -39,5 +39,5 @@ import { takeLast as higherOrderTakeLast } from '../operators/takeLast'; * @owner Observable */ export function takeLast(this: Observable, count: number): Observable { - return higherOrderTakeLast(count)(this); + return higherOrderTakeLast(count)(this) as Observable; } diff --git a/src/operator/takeUntil.ts b/src/operator/takeUntil.ts index f35ffa52e9..75b0c10899 100644 --- a/src/operator/takeUntil.ts +++ b/src/operator/takeUntil.ts @@ -35,5 +35,5 @@ import { takeUntil as higherOrder } from '../operators/takeUntil'; * @owner Observable */ export function takeUntil(this: Observable, notifier: Observable): Observable { - return higherOrder(notifier)(this); + return higherOrder(notifier)(this) as Observable; } diff --git a/src/operator/throttleTime.ts b/src/operator/throttleTime.ts index 5175e824cc..8f9273956f 100644 --- a/src/operator/throttleTime.ts +++ b/src/operator/throttleTime.ts @@ -47,5 +47,5 @@ export function throttleTime(this: Observable, duration: number, scheduler: IScheduler = async, config: ThrottleConfig = defaultThrottleConfig): Observable { - return higherOrder(duration, scheduler, config)(this); + return higherOrder(duration, scheduler, config)(this) as Observable; } diff --git a/src/operator/timeInterval.ts b/src/operator/timeInterval.ts index 4302b519b5..858340541f 100644 --- a/src/operator/timeInterval.ts +++ b/src/operator/timeInterval.ts @@ -11,5 +11,5 @@ export {TimeInterval}; * @owner Observable */ export function timeInterval(this: Observable, scheduler: IScheduler = async): Observable> { - return higherOrder(scheduler)(this); + return higherOrder(scheduler)(this) as Observable>; } diff --git a/src/operator/timeout.ts b/src/operator/timeout.ts index c3af999cf3..4f84a1dc0c 100644 --- a/src/operator/timeout.ts +++ b/src/operator/timeout.ts @@ -71,5 +71,5 @@ import { timeout as higherOrder } from '../operators/timeout'; export function timeout(this: Observable, due: number | Date, scheduler: IScheduler = async): Observable { - return higherOrder(due, scheduler)(this); + return higherOrder(due, scheduler)(this) as Observable; } diff --git a/src/operator/timestamp.ts b/src/operator/timestamp.ts index 9f0b408f94..fc3a5cec13 100644 --- a/src/operator/timestamp.ts +++ b/src/operator/timestamp.ts @@ -10,5 +10,5 @@ import { Timestamp } from '../operators/timestamp'; * @owner Observable */ export function timestamp(this: Observable, scheduler: IScheduler = async): Observable> { - return higherOrder(scheduler)(this); + return higherOrder(scheduler)(this) as Observable>; } diff --git a/src/operator/toArray.ts b/src/operator/toArray.ts index fd087afd04..22d1f79c08 100644 --- a/src/operator/toArray.ts +++ b/src/operator/toArray.ts @@ -8,5 +8,5 @@ import { toArray as higherOrder } from '../operators/toArray'; * @owner Observable */ export function toArray(this: Observable): Observable { - return higherOrder()(this); + return higherOrder()(this) as Observable; } diff --git a/src/operator/toPromise.ts b/src/operator/toPromise.ts index 5af6475d72..5a51312657 100644 --- a/src/operator/toPromise.ts +++ b/src/operator/toPromise.ts @@ -56,5 +56,5 @@ export function toPromise(this: Observable, PromiseCtor: typeof Promise): * @owner Observable */ export function toPromise(this: Observable, PromiseCtor?: typeof Promise): Promise { - return higherOrder(PromiseCtor)(this); + return higherOrder(PromiseCtor)(this) as Promise; } diff --git a/src/operator/window.ts b/src/operator/window.ts index e72e98bfcb..bf13a046b3 100644 --- a/src/operator/window.ts +++ b/src/operator/window.ts @@ -39,5 +39,5 @@ import { window as higherOrder } from '../operators/window'; * @owner Observable */ export function window(this: Observable, windowBoundaries: Observable): Observable> { - return higherOrder(windowBoundaries)(this); + return higherOrder(windowBoundaries)(this) as Observable>; } diff --git a/src/operator/windowCount.ts b/src/operator/windowCount.ts index 63b1f259ff..35e3807bcd 100644 --- a/src/operator/windowCount.ts +++ b/src/operator/windowCount.ts @@ -52,5 +52,5 @@ import { windowCount as higherOrder } from '../operators/windowCount'; */ export function windowCount(this: Observable, windowSize: number, startWindowEvery: number = 0): Observable> { - return higherOrder(windowSize, startWindowEvery)(this); + return higherOrder(windowSize, startWindowEvery)(this) as Observable>; } diff --git a/src/operator/windowTime.ts b/src/operator/windowTime.ts index a600b017c4..4b2c4a3df2 100644 --- a/src/operator/windowTime.ts +++ b/src/operator/windowTime.ts @@ -98,5 +98,5 @@ export function windowTime(this: Observable, windowCreationInterval = arguments[1]; } - return higherOrder(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler)(this); + return higherOrder(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler)(this) as Observable>; } diff --git a/src/operator/windowToggle.ts b/src/operator/windowToggle.ts index 506faa1b8f..bb2a2f9beb 100644 --- a/src/operator/windowToggle.ts +++ b/src/operator/windowToggle.ts @@ -45,5 +45,5 @@ import { windowToggle as higherOrder } from '../operators/windowToggle'; */ export function windowToggle(this: Observable, openings: Observable, closingSelector: (openValue: O) => Observable): Observable> { - return higherOrder(openings, closingSelector)(this); + return higherOrder(openings, closingSelector)(this) as Observable>; } diff --git a/src/operator/windowWhen.ts b/src/operator/windowWhen.ts index 3bc536e9be..623156c354 100644 --- a/src/operator/windowWhen.ts +++ b/src/operator/windowWhen.ts @@ -41,5 +41,5 @@ import { windowWhen as higherOrder } from '../operators/windowWhen'; * @owner Observable */ export function windowWhen(this: Observable, closingSelector: () => Observable): Observable> { - return higherOrder(closingSelector)(this); + return higherOrder(closingSelector)(this) as Observable>; } diff --git a/src/operators/catchError.ts b/src/operators/catchError.ts index ea9eec5610..465c5e68ec 100644 --- a/src/operators/catchError.ts +++ b/src/operators/catchError.ts @@ -67,7 +67,7 @@ export function catchError(selector: (err: any, caught: Observable) => return function catchErrorOperatorFunction(source: Observable): Observable { const operator = new CatchOperator(selector); const caught = source.lift(operator); - return (operator.caught = caught); + return (operator.caught = caught as Observable); }; } diff --git a/src/operators/concat.ts b/src/operators/concat.ts index 0021e78e32..8f3f54f89c 100644 --- a/src/operators/concat.ts +++ b/src/operators/concat.ts @@ -64,7 +64,5 @@ export function concat(...observables: Array | ISched * @owner Observable */ export function concat(...observables: Array | IScheduler>): OperatorFunction { - return function concatOperatorFunction(source: Observable): Observable { - return source.lift.call(concatStatic(source, ...observables)); - }; + return (source: Observable) => source.lift.call(concatStatic(source, ...observables)); } diff --git a/src/operators/defaultIfEmpty.ts b/src/operators/defaultIfEmpty.ts index 5629fc7673..c89a6d64c9 100644 --- a/src/operators/defaultIfEmpty.ts +++ b/src/operators/defaultIfEmpty.ts @@ -39,9 +39,7 @@ export function defaultIfEmpty(defaultValue?: R): OperatorFunction(defaultValue: R = null): OperatorFunction { - return function defaultIfEmptyOperatorFunction(source: Observable) { - return source.lift(new DefaultIfEmptyOperator(defaultValue)); - }; + return (source: Observable) => source.lift(new DefaultIfEmptyOperator(defaultValue)) as Observable; } class DefaultIfEmptyOperator implements Operator { diff --git a/src/operators/merge.ts b/src/operators/merge.ts index 40896565c2..21c58f3fd9 100644 --- a/src/operators/merge.ts +++ b/src/operators/merge.ts @@ -119,5 +119,5 @@ export function mergeStatic(...observables: Array | I return >observables[0]; } - return mergeAll(concurrent)(new ArrayObservable(observables, scheduler)); + return mergeAll(concurrent)(new ArrayObservable(observables, scheduler)) as Observable; } diff --git a/src/operators/mergeAll.ts b/src/operators/mergeAll.ts index ad018ef85a..8904ae86e8 100644 --- a/src/operators/mergeAll.ts +++ b/src/operators/mergeAll.ts @@ -1,4 +1,5 @@ +import { ObservableInput } from '../Observable'; import { mergeMap } from './mergeMap'; import { identity } from '../util/identity'; import { MonoTypeOperatorFunction } from '../interfaces'; @@ -48,5 +49,5 @@ import { MonoTypeOperatorFunction } from '../interfaces'; * @owner Observable */ export function mergeAll(concurrent: number = Number.POSITIVE_INFINITY): MonoTypeOperatorFunction { - return mergeMap(identity, null, concurrent); + return mergeMap(identity as (value: T, index: number) => ObservableInput<{}>, null, concurrent); } \ No newline at end of file diff --git a/src/operators/partition.ts b/src/operators/partition.ts index f31d18ff3f..845087ac20 100644 --- a/src/operators/partition.ts +++ b/src/operators/partition.ts @@ -49,5 +49,5 @@ export function partition(predicate: (value: T, index: number) => boolean, return (source: Observable) => [ filter(predicate, thisArg)(source), filter(not(predicate, thisArg) as any)(source) - ]; + ] as [Observable, Observable]; } diff --git a/src/operators/reduce.ts b/src/operators/reduce.ts index cc95f9cd23..73ec81e2d7 100644 --- a/src/operators/reduce.ts +++ b/src/operators/reduce.ts @@ -69,6 +69,6 @@ export function reduce(accumulator: (acc: R, value: T, index?: number) => return function reduceOperatorFunction(source: Observable): Observable { return pipe(scan((acc, value, index) => { return accumulator(acc, value, index + 1); - }), takeLast(1))(source); + }), takeLast(1))(source) as Observable; }; } diff --git a/src/operators/share.ts b/src/operators/share.ts index a15a264090..57dbcb33b0 100644 --- a/src/operators/share.ts +++ b/src/operators/share.ts @@ -22,5 +22,5 @@ function shareSubjectFactory() { * @owner Observable */ export function share(): MonoTypeOperatorFunction { - return (source: Observable) => refCount()(multicast(shareSubjectFactory)(source)); + return (source: Observable) => refCount()(multicast(shareSubjectFactory)(source)) as Observable; }; diff --git a/src/operators/shareReplay.ts b/src/operators/shareReplay.ts index 64ad6ca58c..6b77042c98 100644 --- a/src/operators/shareReplay.ts +++ b/src/operators/shareReplay.ts @@ -21,5 +21,5 @@ export function shareReplay(bufferSize?: number, windowTime?: number, schedul return (subject = new ReplaySubject(bufferSize, windowTime, scheduler)); } }); - return (source: Observable) => refCount()(connectable(source)); + return ((source: Observable) => refCount()(connectable(source))) as MonoTypeOperatorFunction; }; \ No newline at end of file