I have the example code below:
function BaseEntity(ctr: Function) {
ctr.prototype.id = Math.random();
ctr.prototype.created = new Date();
}
@BaseEntity
class User {
constructor(public name: string) {}
}
let user = new User("Sarah");
console.log(user.id);
When I run this i got
Property 'id' does not exist on type 'User'.
The experimentalDecorators
property is enabled.
What is the problem?