MeWrite Docs

TypeScriptエラー

12件の記事

概要

TypeScriptのコンパイルエラーとランタイムエラーの診断ガイドです。型の不一致、null安全、モジュール解決などの問題を解決します。

どこでエラーが出た?

状況エラー主な原因
型の不一致(コンパイル時)TS2322: Type ‘X’ is not assignable to type ‘Y’型の互換性なし
TS2345: Argument type not assignable引数の型が不一致
プロパティエラーTS2339: Property does not exist on type存在しないプロパティアクセス
Cannot assign to read-only propertyreadonly への代入
null / undefinedObject is possibly ‘undefined’strictNullChecks での未チェック
TS7006: Parameter implicitly has ‘any’ typenoImplicitAny での型注釈不足
モジュールCannot find module型定義・パス設定の問題
ECMAScript imports/exports onlyesModuleInterop 設定
Cannot augment moduleモジュール拡張の構文エラー
デコレータDecorators are not valid hereexperimentalDecorators 設定
ランタイムエラーCannot read properties of nullnull参照
X is not iterable非イテラブルへの反復処理

切り分けフローチャート

TypeScriptエラー発生
├── TSxxxx コンパイルエラー?
│   ├── TS2322 / TS2345: 型の不一致 → type-not-assignable / argument-type-not-assignable
│   ├── TS2339: プロパティが存在しない → property-does-not-exist
│   ├── TS2540: readonly → readonly-property
│   ├── TS7006: implicit any → implicit-any
│   └── TS18048: possibly undefined → object-is-possibly-undefined
├── モジュール関連?
│   ├── "Cannot find module" → cannot-find-module
│   ├── "ECMAScript imports" → esmodule-interop
│   └── "Cannot augment" → module-augmentation
├── デコレータ?
│   └── "not valid here" → decorator-not-valid
└── ランタイムエラー?
    ├── "Cannot read properties of null" → cannot-read-properties-of-null
    └── "is not iterable" → not-iterable
お探しの環境がありませんか?