Skip to content

Commit

Permalink
fix(typings): fix typings for error prone operators like concatAll
Browse files Browse the repository at this point in the history
fixes concatAll, combineAll, exhaust, mergeAll, switch, zipAll.  Also made a few improvements to
how hot and cold observables are typed.  A few compiler errors were fixed due to this change.

fixes #2658 #2493 #2551
  • Loading branch information
david-driscoll committed Jun 22, 2017
1 parent 766b5a7 commit 495bfb7
Show file tree
Hide file tree
Showing 21 changed files with 503 additions and 274 deletions.
92 changes: 48 additions & 44 deletions spec/helpers/marble-testing.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
import {Observable} from '../../dist/cjs/Observable';
import {SubscriptionLog} from '../../dist/cjs/testing/SubscriptionLog';
import {ColdObservable} from '../../dist/cjs/testing/ColdObservable';
import {HotObservable} from '../../dist/cjs/testing/HotObservable';
import {TestScheduler, observableToBeFn, subscriptionLogsToBeFn} from '../../dist/cjs/testing/TestScheduler';

declare const global: any;

export const rxTestScheduler: TestScheduler = global.rxTestScheduler;

export function hot(marbles: string, values?: any, error?: any): HotObservable<any> {
if (!global.rxTestScheduler) {
throw 'tried to use hot() in async test';
}
return global.rxTestScheduler.createHotObservable.apply(global.rxTestScheduler, arguments);
}

export function cold(marbles: string, values?: any, error?: any): ColdObservable<any> {
if (!global.rxTestScheduler) {
throw 'tried to use cold() in async test';
}
return global.rxTestScheduler.createColdObservable.apply(global.rxTestScheduler, arguments);
}

export function expectObservable(observable: Observable<any>,
unsubscriptionMarbles: string = null): ({ toBe: observableToBeFn }) {
if (!global.rxTestScheduler) {
throw 'tried to use expectObservable() in async test';
}
return global.rxTestScheduler.expectObservable.apply(global.rxTestScheduler, arguments);
}

export function expectSubscriptions(actualSubscriptionLogs: SubscriptionLog[]): ({ toBe: subscriptionLogsToBeFn }) {
if (!global.rxTestScheduler) {
throw 'tried to use expectSubscriptions() in async test';
}
return global.rxTestScheduler.expectSubscriptions.apply(global.rxTestScheduler, arguments);
}

export function time(marbles: string): number {
if (!global.rxTestScheduler) {
throw 'tried to use time() in async test';
}
return global.rxTestScheduler.createTime.apply(global.rxTestScheduler, arguments);
import {Observable} from '../../dist/cjs/Observable';
import {SubscriptionLog} from '../../dist/cjs/testing/SubscriptionLog';
import {ColdObservable} from '../../dist/cjs/testing/ColdObservable';
import {HotObservable} from '../../dist/cjs/testing/HotObservable';
import {TestScheduler, observableToBeFn, subscriptionLogsToBeFn} from '../../dist/cjs/testing/TestScheduler';

declare const global: any;

export const rxTestScheduler: TestScheduler = global.rxTestScheduler;

export function hot(marbles: string, values?: void, error?: any): HotObservable<string>;
export function hot<V>(marbles: string, values?: { [index: string]: V; }, error?: any): HotObservable<V>;
export function hot<V>(marbles: string, values?: { [index: string]: V; } | void, error?: any): HotObservable<any> {
if (!global.rxTestScheduler) {
throw 'tried to use hot() in async test';
}
return global.rxTestScheduler.createHotObservable.apply(global.rxTestScheduler, arguments);
}

export function cold(marbles: string, values?: void, error?: any): ColdObservable<string>;
export function cold<V>(marbles: string, values?: { [index: string]: V; }, error?: any): ColdObservable<V>;
export function cold<V>(marbles: string, values?: { [index: string]: V; } | void, error?: any): ColdObservable<V> {
if (!global.rxTestScheduler) {
throw 'tried to use cold() in async test';
}
return global.rxTestScheduler.createColdObservable.apply(global.rxTestScheduler, arguments);
}

export function expectObservable(observable: Observable<any>,
unsubscriptionMarbles: string = null): ({ toBe: observableToBeFn }) {
if (!global.rxTestScheduler) {
throw 'tried to use expectObservable() in async test';
}
return global.rxTestScheduler.expectObservable.apply(global.rxTestScheduler, arguments);
}

export function expectSubscriptions(actualSubscriptionLogs: SubscriptionLog[]): ({ toBe: subscriptionLogsToBeFn }) {
if (!global.rxTestScheduler) {
throw 'tried to use expectSubscriptions() in async test';
}
return global.rxTestScheduler.expectSubscriptions.apply(global.rxTestScheduler, arguments);
}

export function time(marbles: string): number {
if (!global.rxTestScheduler) {
throw 'tried to use time() in async test';
}
return global.rxTestScheduler.createTime.apply(global.rxTestScheduler, arguments);
}
Loading

0 comments on commit 495bfb7

Please sign in to comment.