我下载了一个包含 Angular2-final 的示例 .NET MVC 应用程序。该项目在根目录中有一个 typings.json,在 ng2 应用程序目录中有一个 tsconfig.json。这2个文件是什么关系?这是否代表了在 VS 中配置 TypeScript 的最新最好的方式?是否需要 typings.json 或是否可以配置 tsconfig.json 以涵盖 typings.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"
]
}
这是 typings.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 是 typescript 的类型定义管理器:https://github.com/typings/typings
它使用 typings.json 文件的方式类似于 npm 使用 package.json 文件的方式,用于存储项目需要的类型定义。
tsconfig.json 是 typescript 配置文件,存储 typescript 编译器的配置。
您不需要使用类型,并且可以使用 npmjs.org 上的@types 组织来获取类型定义:https://www.npmjs.com/~types .像这样使用 npm 安装:
npm install --save-dev @types/<module name>
然后将以下内容添加到您的 tsconfig.json 中:
"typeRoots": [
"../node_modules/@types"
]
关于javascript - tsconfig.json 和 typings.json 之间的关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42307425/