INDEX
はじめに
![](https://techlog.site/wp-content/uploads/2024/02/nwe_icon.jpeg)
初めてのTypeScriptを読みました。
その学習を記録します。
![](https://techlog.site/wp-content/uploads/2024/04/picture_large978-4-8144-0036-2.jpeg)
![](https://techlog.site/wp-content/uploads/2024/04/picture_large978-4-8144-0036-2.jpeg)
結論
interface 継承元 {
変数名1: データ型;
}
interface 継承先 extends 継承元 {
変数名2: データ型;
}
メリット
使い方
OK: 問題がないパターン
interface Writing {
title: string;
}
interface Novella extends Writing {
page: number;
}
const MyNovella: Novella = {
page: 100,
title: 'MyNovella',
}
NG: 継承先の型が不足している
interface Writing {
title: string;
}
interface Novella extends Writing {
page: number;
}
const MyNovella: Novella = {
title: 'MyNovella',
}
NG: 継承元の型が不足している
interface Writing {
title: string;
}
interface Novella extends Writing {
page: number;
}
const MyNovella: Novella = {
page: 100,
}