初級 › implicitly has an 'any' type の原因と直し方 › パターン1
implicitly has an 'any' type の原因と直し方
関数のパラメータに型注釈を付けないと、strictモードのTypeScriptは型を推論できず「暗黙のany」としてエラーにします。
1 function double(_________) { ^ 2 return n * 2; 3 } 4 console.log(double(5));
main.ts(1,17): error TS7006: Parameter 'n' implicitly has an 'any' type.
空欄を埋めてコンパイルを通す
strictモードでは、パラメータの型が推論できない場合に型注釈が必須です。n: numberのように明示します。
次の問題