Typescript 如何组合2个CombineTest以绕过6个参数的限制

Typescript 如何组合2个CombineTest以绕过6个参数的限制,typescript,rxjs,Typescript,Rxjs,可以作为输入的参数的最大数量为6 更具体地说,它将一个最多可包含6个元素的数组作为输入。这样,类型将自动推断 因此,如果在下面的代码中我添加了this.someMethodReturningObservable7()我将其打断: someMethod(…){ 返回组合测试([ 此.someMethodReturningObservable1(), 此.someMethodReturningObservable2(), 此.someMethodReturningObservable3(), 此.s

可以作为输入的参数的最大数量为6

更具体地说,它将一个最多可包含6个元素的数组作为输入。这样,类型将自动推断

因此,如果在下面的代码中我添加了
this.someMethodReturningObservable7()
我将其打断:

someMethod(…){
返回组合测试([
此.someMethodReturningObservable1(),
此.someMethodReturningObservable2(),
此.someMethodReturningObservable3(),
此.someMethodReturningObservable4(),
此.someMethodReturningObservable5(),
此.someMethodReturningObservable6(),
this.someMethodReturningObservable7(),//这会导致问题
]).烟斗(
映射([arg1、arg2、arg3、arg4、arg5、arg6、arg7])=>({
arg1,
arg2,
arg3,
arg4,
arg5,
arg6,
arg7,
})),
//多做事
);
}
只要我把它保持在6个参数,它就可以正常工作。如果超过6个,则不会


如何将其分解为多个
CombineTest
,每个最多有6个参数?

您可以将两个CombineTest组合为一个,如下所示:

从“rxjs”导入{of,combinelatetest,interval};
从“rxjs/operators”导入{map,take};
const num0$=of(0作为const);
常量num1$=of(1作为常量);
const num2$=of(2作为const);
常数num3$=共3个常数;
const num4$=of(4为const);
常量num5$=of(5为常量);
常量num6$=共6个常量;
常量num7$=共7个常量;
const num8$=of(8为const);
常量num9$=区间(1000).pipe(取(3),map(()=>9作为常量));
const numsPartOne$=组合测试(num0$、num1$、num2$、num3$、num4$);
const numsPartTwo$=组合测试(num5$、num6$、num7$、num8$、num9$);
const numCombined$=组合测试([numsPartOne$,numsPartTwo$).pipe(
//使用[[..][..]]分散两个数组
地图(([[num0,num1,num2,num3,num4],[num5,num6,num7,num8,num9]])=>{
//num0具有类型0等。
返回{
num0,
num1,
num2,
num3,
num4,
num5,
num6,
num7,
num8,
num9
};
})
);
numCombined$.subscribe(mappedNums=>console.log(mappedNums));

您是否考虑过类似于
组合测试(o1、o2、o3、o4、o5、组合测试(o6、o7).管道(mergeAll())
?@anderigătej是的,它不起作用