Javascript AngularJS:TypeScript编译过程和gulp uglify-有没有办法强迫TS生成函数而不是使用IIFE生成变量?

Javascript AngularJS:TypeScript编译过程和gulp uglify-有没有办法强迫TS生成函数而不是使用IIFE生成变量?,javascript,angularjs,typescript,prototype,minify,Javascript,Angularjs,Typescript,Prototype,Minify,我有AngularJS控制器: ArticleController.prototype = Object.create(BaseController.prototype); /* @ngInject */ function ArticleController (CommunicationService){ //Some code not related with problem } class BaseController { constructor() {

我有AngularJS
控制器

ArticleController.prototype = Object.create(BaseController.prototype);

/* @ngInject */

function ArticleController (CommunicationService){
    //Some code not related with problem
}
class BaseController {
    constructor() {
        //Some code not related with problem
    }
}
通过大口吞咽缩小了尺寸:

return gulp.src(pathsToMinify)
        .pipe(require('gulp-ng-annotate')())
        .pipe(require('gulp-uglify')())
        .pipe(require('gulp-concat')('application.min.js'))
        .pipe(gulp.dest('dist'));
然后我决定从普通Javascript迁移到Typescript,从
BaseController
开始:

ArticleController.prototype = Object.create(BaseController.prototype);

/* @ngInject */

function ArticleController (CommunicationService){
    //Some code not related with problem
}
class BaseController {
    constructor() {
        //Some code not related with problem
    }
}
经过缩小和拼接,我得到:

未捕获的TypeError:无法读取未定义的属性“prototype”

与生产线相关:

ArticleController.prototype = Object.create(BaseController.prototype);
然后我意识到Typescript编译器将BaseController作为IIFE变量:

var BaseController = (function () {
    function BaseController() {

    }
    BaseController.prototype.setPath = function (path) {
        this._path = path;
    };
    //Some code not related with problem
    return BaseController;
})();
IMO的问题与Javascript中的变量/函数提升有关-当我用函数手动替换变量和IIFE时:

function BaseController() {
}
//Some code not related with problem

它工作正常。有没有办法解决这个问题,比如强制Typescript编译器输出函数而不是IIFE变量?或者,我不能改变它,我必须以其他方式处理它?提前感谢您的帮助,我对Typescript非常陌生,我没有意识到我可以找到类似这样的问题。

很可能,
BaseController
ArticleController
中不可见(因为它是在后面连接的)


为避免此类问题,请编写模块化Typescript(es6和/或commonjs样式)并使用webpack或browserify

,很可能,
BaseController
ArticleController
中不可见(例如,因为它在后面连接)。为了避免此类问题,请编写模块化的Typescript(es6和/或commonjs样式)并使用
webpack
browserify
@BrunoGrieder您是对的,它是在之后连接的,并且(使用变量和IIFE)它是以不同的方式提升的(使用函数),这使得我的代码无法工作。请把它作为常规答案-然后我可以把它的答案标记为正确的,它有帮助。回答了我的评论