最近、タイコスクリプトでOOを試していて、いくつかのジェネリッククラスを宣言しようとしています。デフォルトを宣言するための構文
クラスを拡張しようとしていて、クラス自体の中でデフォルト値を宣言していますが、構文エラーが発生しています。
なぜ私の財産はこの状況でのみ読まれるのですか?
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.
};
}