I have been experimenting with OO in typescript lately, and have been trying to declare some generic classes.
I am trying to extend a class, and declare defaulted values inside the class itself, but I am running into a syntax error.
Why would my property be read only in this situation?
export interface Heading {
size: number;
color: number;
}
export class text {
size: number;
color: number;
}
export class Document extends text {
H1: Heading = {
size = 1 // syntax error - Cannot assign to 'Number' because it is a constant or a read-only property.
};
}