【发布时间】:2020-12-28 07:12:49
【问题描述】:
有代码:
ngOnInit(): void {
[this.newReleaseNotes$, this.readReleaseNotes$] = partition(this.getReleaseNotes$(), ({ id }: ReleaseNoteInterface) =>
this.releaseNotesService.readReleaseNotes.includes(id),
);
}
private getReleaseNotes$(): Observable<ReleaseNoteInterface[]> {
return forkJoin(this.releaseNotes.map((releaseNoteId: string) => this.releaseNotesService.fetchReleaseNoteById$(releaseNoteId)));
}
此代码在 TypeScript 中引发错误:
错误 TS2345:'({ id }: ReleaseNoteInterface) => boolean' 类型的参数不可分配给 '(value: ReleaseNoteInterface[], index :数字)=>布尔'。 [0] 参数“__0”和“值”的类型不兼容。 [0] 类型“ReleaseNoteInterface[]”缺少类型“ReleaseNoteInterface”的以下属性:id、type、importance、actuality 等 8 个。
方法 this.releaseNotesService.fetchReleaseNoteById $ 向服务器发出请求并返回Observable<ReleaseNoteInterface>
如何正确使用partition运算符来解决我的问题?
【问题讨论】:
-
你能澄清你想要做什么吗?因为这似乎你在滥用分区
标签: angular rxjs rxjs-observables