I have a generic component that receives a Enum as input:
TableComponent<Columns> {
@Input() columnsEnum: Columns;
}
The Enum looks like this:
export enum CardsEnum {
CODE = 'sCode',
NAME = 'sName',
ID = 'sId'
}
And on my holder template, I have an instance of table-component as this:
<table-component [columnsEnum]="cardsEnum"></table-component>
And on my .ts of the holder component, I have a refererence to the Enum:
cardsEnum = CardsEnum
Angular infer the type of Columns properly, setting this to be CardsEnum. The problem is that on the template where I'm instantiating table-component, I receive the following error on the input:
Type 'typeof CardsEnum' is not assignable to type 'CardsEnum'.
And that's true, If I look to my holder component, the type that my variable stores is typeof CardsEnum, not CardsEnum:
(property) HolderComponent.cardsEnum: typeof CardsEnum
I can bypass the error setting cardsEnum = CardsEnum as unknown as CardsEnum but I don't want to do that.
I can't import the Enum directly on table-component because I'm going to pass different enums to this component, since its a generic component and that's my goal.
Any suggestions on how to fix this error?