簡體   English   中英

我可以將tsconfig文件放在一個項目中並在另一個項目中使用它嗎?

[英]Can I put tsconfig file in one project and use it in another?

我的解決方案項目中有子模塊。 他們兩個(第一個第二個項目)都有.ts文件,所以我想把tsconfig.json放在子模塊中並為它們共享它。

在文件系統中,它們的位置如下:

~/solution
--project1
  --Scripts
    --(ts files)
--submodule
  --tsconfig.json(I want to put it here)

~/solution
--project2
  --Scripts
    --(ts files)
--submodule

project1's name is equal with project2's name

我試圖將rootDir添加到compilerOptions

   "rootDir": "..\\project1\\Scripts\\**\\*"

我試着補充一下

  "include": [
    "..\\project1\\Scripts\\**\\*"
  ]

它們都不適合我。

這是我的tsconfig.json

{
  "compileOnSave": true,
  "buildOnSave": true,
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": true,
    "sourceMap": false,
    "target": "es5",
    "module": "none",
    "types": [],
    "emitBOM": false,
    "charset": "utf8"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

如果要在兩個項目之間共享tsconfig,可以擴展tsconfig.json文件。 例如,您有一個共享文件shared.json 每個項目都有自己的tsconfig.json文件並擴展基本文件shared.json ,如下所示:

{
  "extends": "../shared",
  <options here that are different>
}

關於此頁的更多信息: https//www.typescriptlang.org/docs/handbook/tsconfig-json.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM