Observable.forkJoin invalid return type when more than 6 arguments

I have a problem with Observable.forkJoin outputting the wrong return type and then causing errors when passing more than 6 arguments.

Observable.forkJoin(service.getType1, service.getType2, service.getType3 ...)
        .subscribe(x => {
            this.type1Arr = x[0];
            this.type2Arr = x[1];
            this.type3Arr = x[2];

Each function call from the service returns Observable<Array<type>>. The compiler determines what the return should be Type1[][]when I have more than 6 calls from the transferred service. It works fine until 6, but will have the correct return, and I can assign strongly typed results.

I am using rxjs 5.4.3 and Typescript 2.4.0 (Typescript Tools for Visual Studio - 2.5.2).

Is there a workaround for this without casting it?

+4
source share
1 answer

forkJoin max forkJoin 6 , : https://github.com/ReactiveX/rxjs/blob/master/src/observable/ForkJoinObservable.ts#L27

, forkJoin 6 :

Observable.forkJoin(observables)

Observable.forkJoin(...observables)

(https://github.com/ReactiveX/rxjs/blob/master/src/observable/ForkJoinObservable.ts#L35):

Observable.forkJoin<Whatever[]>(observables)
+4

Source: https://habr.com/ru/post/1686152/


All Articles