初級 › 未定義プロパティを書いたエラーの原因と直し方 › パターン5
未定義プロパティを書いたエラーの原因と直し方
interfaceに定義されていないプロパティを、オブジェクトリテラルに書いてしまったときに出るエラーです。
1 interface Note { 2 text: string; 3 } 4 const n: Note = ____________________________; ^ 5 console.log(n.text);
main.ts(4,31): error TS2353: Object literal may only specify known properties, and 'pinned' does not exist in type 'Note'.
空欄を埋めてコンパイルを通す
Noteにpinnedというプロパティは定義されていません。
次の問題