When attempting to assign a generic type to Type<any>
, I am unable to correctly set the type constraint when I know it is an Angular component.
However, directly assigning a component type does work.
Here is an example that works:
private routeComponent: Type<any>;
public component<TComponent>(): RouteBuilder {
this.routeComponent = HomeComponent;
return this;
}
This, on the other hand, does not work:
private routeComponent: Type<any>;
public component<TComponent>(): RouteBuilder {
this.routeComponent = TComponent;
return this;
}
It results in the following error:
error TS2693: 'TComponent' only refers to a type, but is being used as a value here.
How can I modify my component method to only accept a Component, or if that is not achievable, how can I successfully assign the generic type to Type<any>
like I can when doing it directly?