I was creating an Angular 2 App with some simple routing:
(main.module.ts)
import { routes } from './main.routes';
/* Other imports */
@NgModule({
imports: [
HomeModule,
TestModule,
RouterModule.forRoot(routes) // imported from file below
],
declarations: [MainComponent, SidebarComponent],
exports: [MainComponent, SidebarComponent]
})
(main.routes.ts)
import { Route } from '@angular/router';
/* Other imports */
export const routes = [
{
path: '',
component: MainComponent,
children: [
{ path: 'home', component: HomeComponent },
{ path: 'test', component: TestComponent }
]
}
];
The application runs fine when I type npm start but my IntelliJ IDE is showing error in the line with RouterModule.forRoot(routes)
Argument type {path: string, component: MainComponent, children: {path: string, component: HomeComponent}|{path: string, component: TestComponent}[]}[] is not assignable to parameter Routes
I've also tried:
export const routes: Routes = ] instead of export const routes = [
After searching, I'm unable to find a reason or an alternative to implement it without error.

export const routes: Routes, if you double-click on the typeRoutes, it should take you to the type definition. What does the definition look like, and which file is it in? - BeetleJuice