doc.exists) throw new Error("Missing some document");
} Typescript不允许这样做,因为doc.data()返回类型是DocumentSnapshot | undefined。不知何故,我觉得Typescript应该能够知道doc.data()将返回一个DocumentSnapshot,因为它之前的doc.exists检查。在当前版本的Typescript中使用正确的类型<
我正在尝试做一个用户配置文件页面,在从Firestore获取数据之后,我无法将数据设置为userProfile状态。().collection("Users") .get() if (documentSnapshot.exists) {
console.log('User data from Firestore: &