The error says that afAuth.authState
is null
which does not match the expected type Observable<firebase.User | null>
(which means either Observable<firebase.User>
or Observable<null>
). And that is true. null
is not Observable<null>
and it is definitely not Observable<firebase.User>
.
Looking at the current angularfire docs it looks like AngularFireAuth
is just a thin wrapper around firebase.auth.Auth
that proxies calls and wraps them in Promises
/ Observables
. Those documents also suggest that the correct way to use AngularFireAuth
(currently) to get an Observable<firebase.User | null>
is using the user
property:
AngularFireAuth.user
provides you anObservable<User|null>
to monitor your application’s authentication State.
So instead of this:
You need to do this:
user: Observable<firebase.User|null>;
constructor(private afAuth : AngularFireAuth) {
this.user = afAuth.user;
}