中級 › incorrectly implements interface の原因と直し方 › パターン5
incorrectly implements interface の原因と直し方
クラスがimplementsで宣言したinterfaceのメンバー(メソッドやプロパティ)を実装し忘れたときに出るエラーです。
1 interface Labeled { 2 label: string; 3 } 4 class Item implements Labeled {_________________ ^ 5 } 6 console.log(new Item());
main.ts(4,7): error TS2420: Class 'Item' incorrectly implements interface 'Labeled'.
空欄を埋めてコンパイルを通す
Labeledはlabelプロパティを要求します。Itemクラスにlabelが無いため契約を満たせません。
次の問題