在类型 EventEmitter 上观察到的属性不存在

问题描述

我们使用 angular (11.2.14) 并将 rxjs 库更新到 7.1.0。 从那时起,我们在多个地方出现了这个错误属性 'observers' 在类型 'EventEmitter' 上不存在”。 根据我们发现的公关 (https://github.com/ReactiveX/rxjs/pull/6405#issue-645234112) 应该有一个 observed 属性,但它不可用,因为我们使用的是 EventEmitter 而不是 Subject。

构建时出现错误

@Output() readonly onListCreate: EventEmitter<ListDto> = new EventEmitter(); // our emitter

createList() {
        if (!this.newListName) {
            return;
        }

        this.ListService.createList(this.newListName).subscribe((newList) => {
            const newListviewmodel: Listviewmodel = {
                id: newList.id,name: this.newListName,isAdded: false,};
            this.addModuletoList(newList,newListviewmodel);
            this.newListName = "";

            if (this.onListCreate.observers.length === 0) { // error appears here
                this.listsviewmodel.push(newListviewmodel);
                this.ownedAndCoOwnedLists.push(newList);
            }

            this.onListCreate.emit(newList);
        });
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)