1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【TypeScript】tsconfig.jsonで「設定 "composite": true が必要です」と「生成を無効にできません」が出てきた時の対処法

Posted at

発生した事象

以下のようにtsconfig.jsonファイルを記述したところ、referencesの2つのpathにエラーが発生していました。

tsconfig.json
{
  "files": [],
  "references": [
    { "path": "./tsconfig.app.json" },
    { "path": "./tsconfig.node.json" },
    // tsconfig.app.jsonとtsconfig.node.jsonはルート直下に入っている前提
  ],

  "compilerOptions": {
    "target": "ESNext",
    "useDefineForClassFields": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "types": ["node", "jest", "@testing-library/jest-dom"]
  },
  "include": ["src"],
}

エラーの内容は次の通りでした。

  • 「参照されているプロジェクト '(jsonが格納されたフォルダ)/tsconfig.app.json' には、設定 "composite": true が必要です。」
  • 「参照されたプロジェクト '(jsonが格納されたフォルダ)/tsconfig.node.json' は、生成を無効にできません。」

「設定 "composite": true が必要です。」エラーの対処法

エラーが出ているjsonファイルに"composite": true,の記述を追加します。compilerOptionsの内側であれば場所はどこでもOKです。

tsconfig.app.json
{
  "compilerOptions": {
+  "composite": true,
 }
}

「生成を無効にできません。」エラーの対処法

該当するjsonファイルに含まれている"noEmit": true,の記述を削除します。

tsconfig.app.json
{
  "compilerOptions": {
-   "noEmit": true,
 }
}

最後に

上記の2つの処理を行うことでpath周りのエラーは解消されました。
同じような現象で困っている方の参考になれば幸いです。

参考資料

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?