diff --git a/modules/@angular/router/src/config.ts b/modules/@angular/router/src/config.ts index 25f926fb8f..544bc95ff9 100644 --- a/modules/@angular/router/src/config.ts +++ b/modules/@angular/router/src/config.ts @@ -503,6 +503,9 @@ export function validateConfig(config: Routes): void { } function validateNode(route: Route): void { + if (Array.isArray(route)) { + throw new Error(`Invalid route configuration: Array cannot be specified`); + } if (!!route.redirectTo && !!route.children) { throw new Error( `Invalid configuration of route '${route.path}': redirectTo and children cannot be used together`); diff --git a/modules/@angular/router/test/config.spec.ts b/modules/@angular/router/test/config.spec.ts index 98213b3540..c85377a0f9 100644 --- a/modules/@angular/router/test/config.spec.ts +++ b/modules/@angular/router/test/config.spec.ts @@ -6,6 +6,15 @@ describe('config', () => { validateConfig([{path: 'a', redirectTo: 'b'}, {path: 'b', component: ComponentA}]); }); + it('should throw when Array is passed', () => { + expect(() => { + validateConfig([ + {path: 'a', component: ComponentA}, + [{path: 'b', component: ComponentB}, {path: 'c', component: ComponentC}] + ]); + }).toThrowError(`Invalid route configuration: Array cannot be specified`); + }); + it('should throw when redirectTo and children are used together', () => { expect(() => { validateConfig(