When trying to assign a generic type to Type<any>, i cannot get the type constraint correct when i know the type is an angular component.
However directly assigning a component type works.
This works
private routeComponent: Type<any>;
public component<TComponent>(): RouteBuilder {
this.routeComponent = HomeComponent;
return this;
}
This doesnt.
private routeComponent: Type<any>;
public component<TComponent>(): RouteBuilder {
this.routeComponent = TComponent;
return this;
}
It fails with
error TS2693: 'TComponent' only refers to a type, but is being used as a value here.
How can i make it so my component method accepts only a Component, or if cant do that at least be able to assign the generic type to the Type<any> the same as i can if i do it direct.