Angular type of Components

I have a routesList that I use in the app-routing.module of Angular
The type of the routesList is:

type routesList = {
  [key: string]: {
    path: string;
    title: string;
    component: Type<Component>;

The current list that is being exported is:

export const routesList: routesList = {
  home: {
    path: '',
    title: 'Curation Console',
    component: AppComponent,
  otherpage: {
    path: 'otherpage',
    title: 'Other Page',
    component: OtherPageComponent,

But I’m getting an error for component: AppComponent saying

typescript: Type of 'typeof AppComponent' is not assignable to type 'Type<Component>'.
Type 'AppComponent' has no properties in common with type 'Component'.

Is the Type<Component> incorrect for this use?
Is there another way I could get the type of Angular Components?

>Solution :

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

const routes: Routes = [
    path: "/path1",
    component: component1Name,
    path: "/path2",
    component: component2Name,
   imports: [RouterModule.forChild(routes)],
   exports: [RouterModule],

Leave a Reply