I have a class with multiple methods that deal with an entity referred to as "entity."
class entity {
entityName: string = '';
getList(): any[] {
someAPI + this.entityName ....
}
getOne(): any{
}
}
Additionally, there are specific entities that extend from the base class:
class person extends entity {
entityName: string = 'person';
}
class order extends entity {
entityName: string = 'order';
}
I would like to specify the entity type for each new class. Instead of inheriting the generic method getList(): any[] {}
, I want to customize it for each subclass. For example, in the person
class:
getList(): IPerson[] {
}
And for the order
class:
getList(): IOrder[] {
}
Is there a way to set an interface type in each inherited class similar to how I am setting the entityName
?