if(!userCredentials?.user){
throw new Error(Errors.INVALID_USER)
}```
Error: ```src/app/components/landing/landing.component.ts:45:30 - error TS2339: Property 'user' does not exist on type 'UserCredential | Error'.
Property 'user' does not exist on type 'Error'.
45 if(!userCredentials?.user){```
#Angular firebase UserCredential does not have property user
4 messages · Page 1 of 1 (latest)
Whole function: ```ts
signIn(): void {
this.auth
.login()
.pipe(
this.toasts.observe({
loading: Lang.toastMessages.loading('logging in'),
success: Lang.toastMessages.success('logging in'),
error: ({ message }) => Lang.toastMessages.error('logging in', message),
})
)
.subscribe((userCredentials: UserCredential | Error) => {
console.log('userCredentials', userCredentials);
if(!userCredentials?.user){
throw new Error(Errors.INVALID_USER)
}
this.userService.updateUser({
// uid: userCredentials?.user,
uid: 'exampleUid',
meetings: [],
settings: {
schedule: [],
},
username: '',
});
});
}```
this.auth .login():ts login(): Observable<UserCredential | Error> { return from(signInWithPopup(this.auth, new GoogleAuthProvider())); }
You have to tell TypeScript that it is a UserCredential Object not an Error Object