Property import types are not compatible when using routing

app.routing.ts

import { Routes, RouterModule }   from '@angular/router';

import { LoginComponent }  from './components/login/login.component';
import { TestsComponent }  from './components/tests/tests.component';
import { NotFoundComponent }  from './components/notfound/notfound.component';
import { AppModule }  from './app.module';

const appRoutes: Routes = [
  { path: 'anmelden', component: LoginComponent },
  { path: 'tests', component: TestsComponent },
  { path: '**', component: NotFoundComponent }
];

export const appRoutingProviders: any[] = [

];

export const routing: AppModule = RouterModule.forRoot(appRoutes);

app.module.ts

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { routing,
         appRoutingProviders } from './app.routing';

import { AppComponent }  from './components/app/app.component';
import { LoginComponent }  from './components/login/login.component';
import { TestsComponent }  from './components/tests/tests.component';
import { NotFoundComponent }  from './components/notfound/notfound.component';

@NgModule({
  declarations: [ AppComponent, LoginComponent, TestsComponent, NotFoundComponent ],
  imports: [ BrowserModule, routing ],
  providers: [ appRoutingProviders ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

Result:

enter image description here

Edit: These errors only occur when npm starts. If I delete the import: the line in the module starts npm start and adds this line again, everything works fine.

+4
source share

Source: https://habr.com/ru/post/1653313/


All Articles