【发布时间】:2015-06-15 17:58:14
【问题描述】:
如果我误解了,请原谅我,但我认为如果我在项目根目录中使用tsconfig.json 文件,那么我将不再需要使用任何///<reference path="..." /> 标记来编译我的代码。我错了吗?
例如,我正在使用 AngularJS。我的App.ts 文件看起来像这样:
import SomeModule from './whatever/SomeModule';
angular.module('foo', [SomeModule.name]).run(...);
我的tsconfig.json 文件(部分)如下所示:
{
"compileOnSave": false,
"compilerOptions": {
"target": "es5",
"module": "commonjs"
},
"filesGlob": [
"./www/**/*.ts",
"./typings/**/*.ts"
],
"files": [
/* a bunch of files omitted for brevity*/
"./typings/angularjs/angular.d.ts"
],
}
请注意,我在文件数组中列出了角度定义文件的路径。另请注意,我将 compileOnSave 选项设置为 false。最终我想使用 Browserify 来编译和捆绑所有代码。但现在我只想看看是否可以使用tsc 编译它。
但是当我运行 tsc App.ts 时,我收到一条错误消息,提示“找不到名称 'angular'”。编译代码时如何让TypeScript编译使用angular.d.ts文件?
【问题讨论】:
标签: javascript angularjs typescript tsd