【发布时间】:2015-05-25 21:00:07
【问题描述】:
我正在使用 Typescript 尝试 Angular2,但我遇到了 tsc 的问题。
这是我的 tsconfig.json 文件:
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"out": "compiled.js",
"emitDecoratorMetadata":true,
"target":"es5"
},
"files": [
"ts/_base/_all.ts"
]
}
这是我的 _all.ts 文件:
///<reference path="./typings/libs.d.ts"/>
///<reference path="../app.ts"/>
///<reference path="../controllers/loginCtrl.ts"/>
这是我的应用控制器:
import {Component, View, bootstrap} from 'angular2/angular2';
@Component({
selector: 'my-app'
})
@View({
template: `Hi`
})
class MyAppComponent
{
constructor()
{
}
}
bootstrap(MyAppComponent);
正常运行 tsc 我得到一个输出文件 (compiled.js),但是使用 angular2 我为每个 ts 文件得到一个 .js 文件(所以 tsc 没有合并输出)...
我注意到使用 import 语句存在问题:
import {Component, View, bootstrap} from 'angular2/angular2';
省略这一行,输出被正确合并(但没有导入我无法使用模块)。
我做错了什么?
【问题讨论】:
标签: typescript angular typescript1.5 tsc