- [[クラス (TypeScript)|クラス]]
- [[TypeScriptのstrictPropertyInitializationはコンストラクタの中で呼び出されたメソッドの中まで解析しない]]
- [[コンストラクタ (TypeScript)|コンストラクタ]]
- [[コンストラクタ (TypeScript)|コンストラクタ]]は[[型パラメーター (TypeScript)|型パラメーター]]を持てない
- [[コンストラクタ (TypeScript)|コンストラクタ]]は返却型を持てない
- [[メソッド (TypeScript)|メソッド]]で[[プロパティ (TypeScript)|プロパティ]]にアクセスするには`this`は必須
- [[TypeScriptのgetterとsetter]]
- [[implements (TypeScript)|implements]]
- [[TypeScriptのimplementsではインターフェースのオプショナルプロパティを認識しない]]
```ts
class Parent {
hoge() {}
}
class Child implements Parent {
hoge(message: string) {
console.log(message);
}
}
```
はシグニチャが異なるので[[オーバーライド (TypeScript)|オーバーライド]]はできずにエラーだけど、以下は満たすのでOK.
```ts
class Parent {
hoge() {}
}
class Child implements Parent {
hoge(message?: string) {
// 真面目にやるならmessageでif文を書いた方がいいけど
console.log(message);
}
}
```
`Type-only Field Declarations`について。
- [[【TypeScript 3.7】The useDefineForClassFields Flag and The declare Property Modifier]]を参照
- こんなのあったな...