【发布时间】:2021-04-19 16:18:22
【问题描述】:
我在尝试使用 firebase 设置 Google 身份验证时总是遇到此错误。
参数'user'隐含一个'any'类型.ts(7006)
我到处搜索,但我不知道如何解决它:/
代码:enter code here
user$: Observable<User | null | undefined>;
async googleSignin() {
const provider = new firebase.auth.GoogleAuthProvider();
const credential = await this.afAuth.signInWithPopup(provider);
return this.updateUserData(credential.user);
}
private updateUserData(user) { //This user causes the Error
// Sets user data to firestore on login
const userRef: AngularFirestoreDocument<User> = this.afs.doc(`users/${user.uid}`);
const data = {
uid: user.uid,
email: user.email,
displayName: user.displayName,
photoURL: user.photoURL
}
return userRef.set(data, { merge: true })
}
有人可以帮忙吗:D
此代码的文档:https://fireship.io/lessons/angularfire-google-oauth/
【问题讨论】:
-
给那个参数一个明确的类型?
标签: angular firebase google-authentication