ディベロッパーツールに出てくるエラーいろいろ
研修中に遭遇した、console上に現れるエラー・警告についてまとめました(増えるたび適宜更新)
***
・Missing radix parameter
parseIntを使ったときに何進数でパースするかを引数で指定してない際に出る
引数で渡せば解決
ex)parseInt(’10’,10)
第二引数で10を渡しているので、10進数でパースする
・The key ‘hoge’ is not sorted alphabetically
アルファベット順に並んでないときにでる
対象のものをアルファベット順に変えてあげたら解決
・Declaration of public instance field not allowed after declaration of public instance method. Instead, this should come at the beginning of the class/interface.
変数の宣言はメソッドより手前にしなければいけない
・Shadowed name: ‘hoge’
同じ名前の変数が複数宣言されているため、どちらかを変更したら解決
・Use an interface instead of a type literal.
typeリテラルよりinterfaceを使えば解決
・Identifier 'hoge’ is never reassigned; use 'const' instead of 'let'.
Letで宣言したhogeが再度代入されることがないため、constを使うように言われている
再代入することがないならconstにするべき
・An empty interface is equivalent to `{}`.
空オブジェクトのinterfaceを許可していないときに出る
許可するなりで解決
・[mobx] @action fields are not reassignable
@action.boundしているメソッドがあるクラスの子クラスでも@action.boundしている同じ名前のメソッドを作った場合に遭遇
子クラスのメソッド名を変えれば解消?
・validateDOMNesting(...): cannot appear as a child of .
タグ直下で