Skip to content

Commit

Permalink
Merge pull request #2787 from cartant/issue-2784-zip
Browse files Browse the repository at this point in the history
chore(typings): improve zip typings
  • Loading branch information
kwonoj authored Sep 1, 2017
2 parents d926435 + 96c142c commit 76668a9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/operators/zip-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {expect} from 'chai';
import * as Rx from '../../dist/cjs/Rx';
import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports

declare const type;
declare const hot: typeof marbleTestingSignature.hot;
declare const cold: typeof marbleTestingSignature.cold;
declare const expectObservable: typeof marbleTestingSignature.expectObservable;
Expand Down Expand Up @@ -595,4 +596,28 @@ describe('Observable.prototype.zip', () => {
expectSubscriptions(a.subscriptions).toBe(asubs);
expectSubscriptions(b.subscriptions).toBe(bsubs);
});

type('should support rest parameter observables', () => {
/* tslint:disable:no-unused-variable */
let o: Rx.Observable<number>;
let z: Rx.Observable<number>[];
let a: Rx.Observable<number[]> = o.zip(...z);
/* tslint:enable:no-unused-variable */
});

type('should support projected rest parameter observables', () => {
/* tslint:disable:no-unused-variable */
let o: Rx.Observable<number>;
let z: Rx.Observable<number>[];
let a: Rx.Observable<string[]> = o.zip(...z, (...r) => r.map(v => v.toString()));
/* tslint:enable:no-unused-variable */
});

type('should support projected arrays of observables', () => {
/* tslint:disable:no-unused-variable */
let o: Rx.Observable<number>;
let z: Rx.Observable<number>[];
let a: Rx.Observable<string[]> = o.zip(z, (...r) => r.map(v => v.toString()));
/* tslint:enable:no-unused-variable */
});
});
1 change: 1 addition & 0 deletions src/operator/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function zipProto<T, T2, T3>(this: Observable<T>, v2: ObservableInput<T2>
export function zipProto<T, T2, T3, T4>(this: Observable<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>): Observable<[T, T2, T3, T4]>;
export function zipProto<T, T2, T3, T4, T5>(this: Observable<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>): Observable<[T, T2, T3, T4, T5]>;
export function zipProto<T, T2, T3, T4, T5, T6>(this: Observable<T>, v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>): Observable<[T, T2, T3, T4, T5, T6]> ;
export function zipProto<T>(this: Observable<T>, ...observables: Array<ObservableInput<T>>): Observable<T[]>;
export function zipProto<T, R>(this: Observable<T>, ...observables: Array<ObservableInput<T> | ((...values: Array<T>) => R)>): Observable<R>;
export function zipProto<T, R>(this: Observable<T>, array: Array<ObservableInput<T>>): Observable<R>;
export function zipProto<T, TOther, R>(this: Observable<T>, array: Array<ObservableInput<TOther>>, project: (v1: T, ...values: Array<TOther>) => R): Observable<R>;
Expand Down

0 comments on commit 76668a9

Please sign in to comment.