LoginSignup
0
1

More than 1 year has passed since last update.

【TypeScript】parameter implicitly has an 'any' type

Posted at

エラー内容

JavaScriptコードをTypeScript化しようとしていた時、

function titleCheck(title){
        if(jsonData[title] != undefined){
            return jsonData[title];
        }else{
            message.channel.send("そのゲームは登録されていません");
            return null;
        }
    }

という関数がもともとあったんですが、
スクリーンショット 2023-01-17 142103.png
というエラー発生。

解決策

1. 引数の型を明記する

any型を持たないように、きちんと型を明記しておくというシンプルな解決法。

function titleCheck(title: string){
     //略
    }

2. tsconfig.jsonを書き換える

80行目くらいにある

// "noImplicitAny": true,                            /* Enable error reporting for expressions and declarations with an implied 'any' type. */

の部分を

"noImplicitAny": false

に書き換えるとエラー消えました。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1