As your guard canActivate methods return type is boolean and you are not return any thing you are getting the error.
You can return a boolean to resolve this issue. But in your case I can see is your return type will be observable and inside the observable you want to return true or false.
So you change you guard t.
you need to do 2 thing as below
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): : boolean | Observable<boolean> | Promise<boolean> {
return firebase.auth().onAuthStateChanged((user: firebase.User) => {
if (user) {
return true;
}
return false;
});
}
You need to check what is the return type of firebase.auth().onAuthStateChanged() normally these kind of methods returns observable. If that is the case then you need to change it to as below
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): : boolean | Observable<boolean> | Promise<boolean> {
return firebase.auth().onAuthStateChanged().map((user: firebase.User) => {
if (user) {
return true;
}
return false;
});
}
returnbeforefirebase(and change the function signature to returnObservable<boolean>). - John Montgomery