As covered a few newsletters ago, Route guards are meant to be functions with Angular 15+. Angular 16 removes the support for class guards.
Does that mean we have to migrate our old class guards manually? Of course not! The Angular team has our back, and the Angular CLI will remove the deprecated interfaces automatically when upgrading to Angular 16 as follows:
Then, if you want to keep your guards as classes, you can do so using a helper function called mapToCanActivate
:
Or you can, of course, decide to use a function instead: