Adi99 Adi99 - 5 months ago 66
TypeScript Question

How to handle precompile array warning using simple router in angular2

I am trying to create simple router based application in Angular2 using typescript. My Angular2 version is

and router version is

My Routes configuration follows-


import { provideRouter, RouterConfig } from '@angular/router';
import { PageNotFoundComponent } from './Shared/pageNotFound.component';
import { Page1Component } from './Pages/Page1/page1.component';
import { Page2Component } from './Pages/Page2/page2.component';

const routes: RouterConfig = [

{ path: 'page1', component: Page1Component },
{ path: 'page2', component: Page2Component },
{ path: '**', component: PageNotFoundComponent }

export const appRouterProviders = [

While running application using npm start command I receives one warning (not error). Please refer this screen shot for warning

How do I overcome this warning?


Try adding below line in your main AppComponent-

  precompile: [Page1Component, Page2Component .... ]

See if this helps.