xxxxxxxxxx
//Change this...
const myVar = 123;
//To this...
readonly myVar = 123;
xxxxxxxxxx
class MyClass {
readonly myReadOnlyProperty = 1;
myMethod() {
console.log(this.myReadOnlyProperty);
this.myReadOnlyProperty = 5; // error, readonly
}
}
new MyClass().myReadOnlyProperty = 5; // error, readonly