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