I have a class with a readonly attribute that I define inside a function
inside the constructor
, the compiler issues an error I do not know how to solve:
class TEST {
public readonly desc: string;
constructor() {
const compute = () => {
this.desc = "description"
};
}
}
The compiler says: "Cannot assign to "desc" because it is a readonly property"
but I thought that assigning the property inside the constructor will avoid this kind of errors.
Is it possible or do I have to change implementation?