I'm doing this in one of my route guards...
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
// go through each check sequentially, stop process if one does throwError
return of(true).pipe( // Is there a limit to operators in a pipe???
switchMap(() => of(true)), // simplified for this post...usually call a function that returns
switchMap(() => of(true)),
switchMap(() => of(true)),
switchMap(() => of(true)),
switchMap(() => of(true)),
switchMap(() => of(true)),
switchMap(() => of(true)),
switchMap(() => of(true)),
// if any function returns throwError, we skip other checks
catchError(() => of(false))
);
}
I'm running into an error. If there is one more switchMap added to the list, VSCode tells me... "Type 'Observable<{}>' is not assignable to type 'Observable'. Type '{}' is not assignable to type 'boolean'.ts(2322)"
Can somebody explain to me why that's the case? I can't figure it out and find related issues.