LoginSignup
2
2

More than 3 years have passed since last update.

【TypeScript】node_modulesでnoImplicitAnyのエラーが出てた場合の対処法

Last updated at Posted at 2019-08-27

npm パッケージの exceljs というものを使っていて、
公開されている node_modules/exceljs/index.d.tsprotect(...) , unprotect() の戻り値の型が指定されていなくてnoImplicitAnyエラーが出ていた(excludeでnode_modulesは除外されると思っていたので原因はよくわからない)。
実際エラーが出ていた箇所

自分で d.ts 型定義で上書きできるか試してみたりしたがエラーは消えず。
noImplitAnyのチェックを true にしたかったので困ったが以下の対応で解決。

解決方法

tsconfig.jsonskipLibChecktrue を指定するだけ。

tsconfig.json
{
    "skipLibCheck": true
}

d.tsで宣言されている型定義ファイルの型チェックをしなくなる。
型情報は生きているので今回はこれで対応。

一応最近exceljs側の方でPRが出てるっぽいhttps://github.com/exceljs/exceljs/pull/930。
こっちが治れば問題ない。

2
2
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
2
2