簡體   English   中英

tsconfig.json和Types.json之間的關系?

[英]relationship between tsconfig.json and typings.json?

我下載了一個包括Angular2-final的示例.NET MVC應用程序。 該項目的根目錄為types.json,ng2應用程序目錄為tsconfig.json。 這兩個文件之間是什么關系? 這是否代表在VS中配置TypeScript的最新和最佳方法? 是types.json是必需的,還是可以將tsconfig.json配置為涵蓋types.json中的功能? 這是tsconfig.json:

{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "noEmitOnError": true,
    "noImplicitAny": false,
    "outDir": "../Scripts/",
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "moduleResolution": "node"
  },
  "exclude": [
    "node_modules",
    "typings/index",
    "typings/index.d.ts"
  ]
}

這是types.json:

{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160725163759",
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
    "node": "registry:dt/node#6.0.0+20160909174046"
  }
}

Typings是打字稿的類型定義管理器: https : //github.com/typings/typings

它與npm使用package.json文件的方式類似,使用Types.json文件,用於存儲項目所需的類型定義。

tsconfig.json是打字稿配置文件,用於存儲打字稿編譯器的配置。

不需要使用類型,可以使用npmjs.org上的@types組織獲取類型定義: https ://www.npmjs.com/~types。 像這樣用npm安裝:

npm install --save-dev @types/<module name>

然后將以下內容添加到您的tsconfig.json中:

  "typeRoots": [
    "../node_modules/@types"
  ]

暫無
暫無

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

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