Is it possible to add new attributes with modifiers using decorators in typescript. I am using ts-lombok to generate getters and setters and I want to use this inside another decorator, so when I use a attribute, I will call the attribute like this: entity.getId()
instead of entity.id
.
class Base {
@Getter @Setter
private id: number;
}
@Base
class Entity { ... }
const entity = new Entity();
entity.getId();
I found another a solution in the question "How to add a new property to a class using class decorator?", but it isn't the way I am looking to encapsulate common attributes and without using inheritance.