@@ -141,29 +141,25 @@ function validateNode(route: Route, fullPath: string, requireStandaloneComponent
141141 `Invalid configuration of route '${ fullPath } ': children and loadChildren cannot be used together` ,
142142 ) ;
143143 }
144+ if ( route . redirectTo && ( route . component || route . loadComponent ) ) {
145+ throw new RuntimeError (
146+ RuntimeErrorCode . INVALID_ROUTE_CONFIG ,
147+ `Invalid configuration of route '${ fullPath } ': redirectTo and component/loadComponent cannot be used together` ,
148+ ) ;
149+ }
144150 if ( route . component && route . loadComponent ) {
145151 throw new RuntimeError (
146152 RuntimeErrorCode . INVALID_ROUTE_CONFIG ,
147153 `Invalid configuration of route '${ fullPath } ': component and loadComponent cannot be used together` ,
148154 ) ;
149155 }
150-
151- if ( route . redirectTo ) {
152- if ( route . component || route . loadComponent ) {
153- throw new RuntimeError (
154- RuntimeErrorCode . INVALID_ROUTE_CONFIG ,
155- `Invalid configuration of route '${ fullPath } ': redirectTo and component/loadComponent cannot be used together` ,
156- ) ;
157- }
158- if ( route . canMatch || route . canActivate ) {
159- throw new RuntimeError (
160- RuntimeErrorCode . INVALID_ROUTE_CONFIG ,
161- `Invalid configuration of route '${ fullPath } ': redirectTo and ${ route . canMatch ? 'canMatch' : 'canActivate' } cannot be used together.` +
162- `Redirects happen before guards are executed.` ,
163- ) ;
164- }
156+ if ( route . redirectTo && route . canActivate ) {
157+ throw new RuntimeError (
158+ RuntimeErrorCode . INVALID_ROUTE_CONFIG ,
159+ `Invalid configuration of route '${ fullPath } ': redirectTo and canActivate cannot be used together. Redirects happen before activation ` +
160+ `so canActivate will never be executed.` ,
161+ ) ;
165162 }
166-
167163 if ( route . path && route . matcher ) {
168164 throw new RuntimeError (
169165 RuntimeErrorCode . INVALID_ROUTE_CONFIG ,
0 commit comments