本文へスキップ
BecomeCoder

TypeScriptのエラー · エラー5

TS7006: Parameter implicitly has an 'any' type ― 引数に型注釈がない

noImplicitAny 有効時、引数に型を書かないと出ます。

出るコード

function greet(name) {   // name の型が無い
  return "Hi " + name;
}

エラーメッセージ

error TS7006: Parameter 'name' implicitly has an 'any' type.

直し方

引数に型注釈を付けます(function greet(name: string))。