LoginSignup
4

More than 5 years have passed since last update.

tsconfig.json:型定義ファイルのエラー対処法

Last updated at Posted at 2018-02-21

tsconfig.json の設定に影響して
型定義ファイル(*.d.ts)から型チェックエラーが大量に出てしまった時の対処法です。

自環境
* Angular 4.4.6
* TypeScript 2.6.2


事象

ASP.NET MVC と Angular4 でアプリ開発を行っています。
この度、TypeScript のお勉強も兼ねて tsconfig.json の設定を触っていたところ
こんなエラーが大量に出て実行できなくなりました。

  • エラー TS2420 クラス '****' はインターフェイス '****' を正しく実装していません。
  • Error TS2420 Class '****' incorrectly implements interface '****'.

image.png

こういう、どうやら型定義ファイルで(*.d.ts)エラーが出ているのが、大量に。

対処

tsconfig.json の compilerOptions 下に以下2つのプロパティを追加

tsconfig.json
{
  "compilerOptions": {
    "skipLibCheck": true,          // すべての型定義ファイル(*.d.ts)の型チェックをスキップする
    "noStrictGenericChecks": true, // 関数型の汎用シグネチャの厳密なチェックを無効にする
  },
}

無事エラーがでなくなりました。
exclude に 型定義ファイルを除外する記述を追記するのかと思いきや、プロパティが用意されてるんですね。
とっぴんぱらりのぷう

参考:

  1. @angular/core is not compatible with Typescript 2.4.1 when activating option strictNullChecks #17863 - GitHub
  2. Compiler Options - TypeScript

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
4