diff --git a/spec/helpers/test-helper.ts b/spec/helpers/test-helper.ts index ea290e8f1d7..37f1145cb6f 100644 --- a/spec/helpers/test-helper.ts +++ b/spec/helpers/test-helper.ts @@ -71,6 +71,11 @@ export function fit(expectation: string, assertion?: (done?: DoneSignature) => v } } +export function type(assertion: Function): void { + //intentionally does not execute to avoid unexpected side effect occurs by subscription, + //or infinite source. Suffecient to check build time only. +} + export function lowerCaseO(...args): Rx.Observable { const values = [].slice.apply(arguments); diff --git a/spec/operators/toArray-spec.ts b/spec/operators/toArray-spec.ts index 65038547eba..20c6f6791c0 100644 --- a/spec/operators/toArray-spec.ts +++ b/spec/operators/toArray-spec.ts @@ -1,6 +1,6 @@ import * as Rx from '../../dist/cjs/Rx'; import {hot, cold, expectObservable, expectSubscriptions} from '../helpers/marble-testing'; -import {it, asDiagram} from '../helpers/test-helper'; +import {it, asDiagram, type} from '../helpers/test-helper'; const Observable = Rx.Observable; @@ -101,4 +101,12 @@ describe('toArray', () => { expectObservable(e1.toArray()).toBe(expected); expectSubscriptions(e1.subscriptions).toBe(e1subs); }); + + type(() => { + const typeValue = { + val: 3 + }; + + Observable.of(typeValue).toArray().subscribe(x => { x[0].val.toString(); }); + }); });