So here is the authService.ts :
user$: Observable<firebase.User>
constructor(private afAuth: AngularFireAuth) {
this.user$ = afAuth.authState ; //<-------- here's the problem
}```
So here is the authService.ts :
user$: Observable<firebase.User>
constructor(private afAuth: AngularFireAuth) {
this.user$ = afAuth.authState ; //<-------- here's the problem
}```
It depends on your intention, do you want to allow null?
If so, just change the typing on your user$:
user$: Observable<firebase.User|null>
If you don't want null, you could filter out null emissions:
this.user$ = afAuth.authState.pipe(
filter(u => !!u)
)
I am using vanilla script so I had to made custom observable to achieve that
this.userob=new Observable(observe=>{
auth.onAuthStateChanged(x=>{
observe.next(x);
})
})
I solved this as below
First I add .map<firebase.User>()
then I add <firebase.User | null>
This gave me error on .map method in VS Code but on this.user$ = afAuth.authState; error was removed.
So I saved file and removed .map.