Im trying to create a Google SignIn with Firestorm. But to many things have chanced since the creation of the guide and i cant find an answer :(
So the Problem is:
export class AuthService {
  
  user$: Observable<User>; //This Observable can be NULL or undefined.
  constructor(
        private afAuth: AngularFireAuth,
        private afs: AngularFirestore,
        private router: Router
  ) {
    
    this.user$ = this.afAuth.authState.pipe(   //this one is not assignable to null or undefined
      switchMap(user => {
          // Logged in
        if (user) {
          return this.afs.doc<User>(`users/${user.uid}`).valueChanges();
        } else {
          // Logged out
          return of(null);
        }
      })
    )
    
   }
}
Im always getting this error:
Type 'Observable<User | null | undefined>' is not assignable to type 'Observable'. Type 'User | null | undefined' is not assignable to type 'User'. Type 'undefined' is not assignable to type 'User'.ts(2322)
But i cant figure out what to to.
Thats the original documetation:
https://fireship.io/lessons/angularfire-google-oauth/
In your method you can possibly return null so you to have declare the user$ Observable as possibly null or undefined as well
  user$: Observable<User | null | undefined>;
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With