Ionic framework 更新到ionic 5和Angular 9后,错误TS2698:只能从对象类型创建排列类型

Ionic framework 更新到ionic 5和Angular 9后,错误TS2698:只能从对象类型创建排列类型,ionic-framework,Ionic Framework,更新到Ionic 5和Angular 9后,我得到以下错误: 错误TS2698:只能从对象类型创建排列类型 src/app/providers/firestore db.service.ts中出错:19:13-错误 TS2698:只能从对象类型创建排列类型。[ng]19 …doc.payload.doc.data() 这是相关代码: 从'@angular/core'导入{Injectable}; 从'@angular/fire/firestore'导入{AngularFirestore}; 从

更新到Ionic 5和Angular 9后,我得到以下错误:

错误TS2698:只能从对象类型创建排列类型

src/app/providers/firestore db.service.ts中出错:19:13-错误 TS2698:只能从对象类型创建排列类型。[ng]19
…doc.payload.doc.data()

这是相关代码:

从'@angular/core'导入{Injectable};
从'@angular/fire/firestore'导入{AngularFirestore};
从“rxjs/operators”导入{map};
@注射的({
providedIn:'根'
})
导出类FirestoreDbService{
构造函数(私有数据库:AngularFirestore){}
getAllData(collectionId){
/*返回此.db.collection('product').valueChanges()*/
返回此.db.collection(collectionId).snapshotChanges().pipe(
映射(docArray=>{
返回docArray.map(doc=>{
返回{
id:doc.payload.doc.id,
…doc.payload.doc.data()
}
})
})
)
}
异步插入数据(collectionId,数据){
试一试{
const result=wait this.db.collection(collectionId).add(data);
返回结果;
}捕获(错误){
抛出新错误(Error);
}
}
异步getDataById(collectionId,docId){
试一试{
const result=wait this.db.collection(collectionId).doc(docId.ref.get();
if(result.exists){
返回result.data();
}否则{
抛出新错误(“未找到具有给定id的数据”);
}
}捕获(错误){
抛出新错误(Error);
}
}
异步更新数据(collectionId、docId、updateData){
试一试{
const result=wait this.db.doc(`${collectionId}/${docId}').update(updatedata);
返回结果;
}捕获(错误){
抛出新错误(Error);
}
}
异步删除数据(collectionId、docId){
试一试{
const result=wait this.db.doc(`${collectionId}/${docId}').delete();
返回结果;
}捕获(错误){
抛出新错误(Error);
}
}

}
我通过将typescript从3.7.5降级到3.6.4解决了这个问题

npm install typescript@3.6.4

请确保它在包中也是3.6.4版本。json

谢谢,我知道它不太理想,但我想微软正在这方面下功夫:s