Angular NG RX从5.x升级到6.0,在Combindatest中给出了汇编误差



我正在使用代码中的ComminElatest,并且我传递了6个以上的参数。我们刚刚从5.x升级到6.0,这给出了编译错误。这是它的示例代码。

https://stackblitz.com/edit/typescript-8znsia?file=index.ts

错误:

类型'operatorFunction< [字符串,数字,数字,字符串, 数字,数字,数字],字符串>'不能分配给参数 键入"操作员"。键入'[字符串,数字, 数字,字符串,数字,数字,数字]'不能分配给类型 '细绳[]'。 属性" pop"的类型是不兼容的。 类型'((=>字符串|数字"不能分配给type'((=>字符串'。 类型'字符串|数字"不能分配给'字符串'。 键入'number'不能分配给类型'字符串'


编辑

它不适用于操作员。

https://stackblitz.com/edit/typescript-krkep6?file=index.ts

New error: Argument of type 'OperatorFunction<string, {}>' is not assignable to parameter of type 'OperatorFunction<ActionName, {}>'.
  Type 'string' is not assignable to type 'ActionName'

应调整您的导入语句。您阅读了升级指南吗?

https://github.com/reactivex/rxjs/blob/master/docs_app/content/guide/guide/v6/migration.md

应该从" rxjs"导入组合,并应从'rxjs/operators''

导入地图

rxjs 6.2.1似乎已经消失了,如果可以的话,请升级。

否则将<any>添加到combineLatest应该消除错误。

combineLatest<any>(..)

请参阅:https://github.com/reactivex/rxjs/issues/3601#issuecomment-384711601

combineLatest从可管道的操作员变为rxjs 6

中的函数

现在您从顶级导入它

import { combineLatest } from 'rxjs';

然后您将可观察到的功能传递到函数

combineLatest(a, b);

而不是旧方法

a.pipe(combineLatest(b));

最新更新