我正在使用Typescript进行Angular编码,而且因为Angular为我加载了模块,我所拥有的只是在我文件顶部的导入,如下所示:
import User = require('modules/user');
import Login = require('modules/login');
module Base {
module Services {
export class UserState {
static $inject: string[] = ['$user'];
constructor(private $user: User.Services.$user){ }
}
}
angular.module('Base', ['User', 'Login']).service('UserState', Services.UserState);
}
export = Base;
这将创建模块" Base"并且已经加载了user.ts
和login.ts
个文件,但事实并非如此。因为我没有使用User和Login的任何导出,所以生成的Base模块是:
var Base;
(function (Base) {
var Services;
(function(Services){
var UserState = (function () {
function UserState($user) {
this.$user = $user;
}
UserState.$inject = ['$user'];
return UserState;
})();
Services.UserState = UserState;
})(Services || (Services = {}));
angular.module('Base', ['User', 'Login']).service('UserState', Services.UserState);
})(Base || (Base = {}));
module.exports = Base;
如何强制打字稿包含CommonJS需要调用而不需要引用文件?