エントリーの編集
![loading...](https://b.st-hatena.com/bdefb8944296a0957e54cebcfefc25c4dcff9f5f/images/v4/public/common/loading@2x.gif)
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
記事へのコメント22件
![アプリのスクリーンショット](https://b.st-hatena.com/bdefb8944296a0957e54cebcfefc25c4dcff9f5f/images/v4/public/entry/app-screenshot.png)
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
TypeScriptにおける配列の共変性
const animal: Animal = { animal: "string", }; const dog: Dog = { animal: "string", dog: "string",... const animal: Animal = { animal: "string", }; const dog: Dog = { animal: "string", dog: "string", }; いま,Dog <: Animalです. <:という記号は2つの型のあいだに書いて,「左の型が右の型のサブタイプである」と読みます. TypeScriptの型システムは構造的なので,2つのオブジェクトがサブタイプ関係にあるには,それらに共通するプロパティについてもまた,サブタイプ関係が必要1です. 今回の例では,DogとAnimalに共通するanimalプロパティについてstring <: stringなのでOKです. TSでは,S <: TならばT型の変数にS型の値を代入できます. つまり,Dog <: Animalなので Animal型の変数にDog型の値を代入できます.
2022/12/15 リンク