我最近从Angular 5更新到Angular 6 .
我收到了这个警告 combineLatest is deprecated: resultSelector no longer supported, pipe to map instead
. Rxjs是版本6.1.0,tslint是5.10.0,Angular CLI是6.0.0和Typescript 2.7.2 . 我这样使用它:
const a$ = combineLatest(
this.aStore.select(b.getAuth),
this.cStore.select(b.getUrl),
(auth, url) => ({auth, url}),
);
我也尝试过这样:
empty().pipe(
combineLatest(...),
...
)
但这给了我: combineLatest is deprecated: Deprecated in favor of static combineLatest
和empty也被弃用,而不是静态版本 .
4 回答
上面的警告建议删除resultSelector你在combineLatest observable中提供的最后一个函数,并将其作为map运算符的一部分提供,如下所示
对于
trailing comma
错误,请删除(auth, url) => ({auth, url})
之后的逗号对于
missing import
错误,请确保您具有文件中正在使用的所有外部var或类的导入 .例如,在这种情况下,如果您还没有导入
combineLatest
,则导入它linting错误的答案:
可以在这个stackoverflow问题中找到:
combineLatest is deprecated: Deprecated in favor of static combineLatest
不幸的是,如果从运算符导入combineLatest,也可能会出现tslint错误:
代替,