i write below code as my main page guard that use checkTokenValidation() to valid authentication token from user but my IDE show this error :A function whose declared type is neither 'void' nor 'any' must return a value.
i return in my subscribe boolean but i don't know why i have this problem. i test my code and understand my code does not execute my return line as true or false and it is strange.
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
this.authService.checkTokenValidation().subscribe((data) => {
console.log(data);
if (data['ok']) {
this.router.navigate(['/overview']);
return false;
} else {
return true;
}
});
}
canActivate. Its a common rookie mistake. - Antoniossss