Javascript 事务处理后检测到无法访问的代码

Javascript 事务处理后检测到无法访问的代码,javascript,angular,firebase,google-cloud-firestore,unreachable-code,Javascript,Angular,Firebase,Google Cloud Firestore,Unreachable Code,我在typescript文件中收到“检测到无法访问的代码”警告。运行Firebase事务后,一切都不起作用。以下是交易代码: //创建Firestore引用 让pointsRef='Users/'+this.user.uid; var pointsDocRef=this.afs.doc(pointsRef).ref; 返回此.afs.firestore.runTransaction((事务)=>{ 返回事务.get(pointsDocRef).then((ptsDoc)=>{ 如果(!ptsDo

我在typescript文件中收到“检测到无法访问的代码”警告。运行Firebase事务后,一切都不起作用。以下是交易代码:

//创建Firestore引用
让pointsRef='Users/'+this.user.uid;
var pointsDocRef=this.afs.doc(pointsRef).ref;
返回此.afs.firestore.runTransaction((事务)=>{
返回事务.get(pointsDocRef).then((ptsDoc)=>{
如果(!ptsDoc.存在){
抛出“文档不存在!”
}
var newPtsScore=ptsDoc.data().points-20;
update(pointsDocRef,{points:newptsCore});
});
}).然后(()=>{
log('新项目的点数已成功递减');
//关闭对话框
this.dialog.closeAll();
}).catch(函数(错误){console.log('Transaction failed:',error);});

console.log('Hey there!') 日志行紧跟在
return
语句之后。It行永远不会运行,因为
return
离开函数。

您的日志行紧跟在
return
语句之后。It行永远不会运行,因为
return
离开该函数。

您有一个在上面的返回:return this.afs…您有一个在上面的返回:return this.afs…哪个返回语句?与日志行位于同一列的语句。第一个。另一个函数中的第二个函数。@FiringBlanks
return this.afs.firestore 5])…
是一次返回,然后在函数返回后尝试打印。这就是根据文档完成事务的方式。这是否意味着每个文件只能有一个事务,后面不能有代码?@FiringBlanks您必须返回
runTransaction
?哪个返回语句?与日志行位于同一列的语句。第一个。另一个函数中的第二个函数。@FiringBlanks
return this.afs.firestore 5])…
是一次返回,然后在函数返回后尝试打印。这就是根据文档完成事务的方式。这是否意味着每个文件只能有一个事务,后面没有代码?@FiringBlanks您必须返回
runTransaction
的结果吗?