我通过NuGet安装了AngularJS,Jasmine和jQuery的类型定义: typings-files structure
这是我的tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "umd",
"sourceMap": true,
"typeRoots": [ "./Scripts/typings" ],
"types": [ "jasmine", "angularjs", "jquery" ]
},
"compileOnSave": true,
"include": [
"Areas/Internet/Scripts/**/*.ts",
"Areas/Internet/Scripts/*.ts"
]
}
构建项目时出现以下错误:
Error Build:Cannot find type definition file for 'jquery'.
Error Build:Cannot find type definition file for 'jasmine'.
Error Build:Cannot find type definition file for 'angularjs'.
通过在每个文件夹中创建一个index.d.ts文件来解决问题,引用其他文件 - 例如对于angularjs,index.d.ts看起来像:
/// <reference path="angular.d.ts" />
/// <reference path="angular-animate.d.ts" />
/// <reference path="angular-component-router.d.ts" />
/// <reference path="angular-cookies.d.ts" />
/// <reference path="angular-mocks.d.ts" />
/// <reference path="angular-resource.d.ts" />
/// <reference path="angular-route.d.ts" />
/// <reference path="angular-sanitize.d.ts" />
我只是想知道为什么有一个名为index 的文件是必要的。看起来像nuget-installation应该默认工作,我在文档中找不到任何相关内容。