【问题标题】:Why does Typescript NOT need typescript-runtime, the way traceur needs traceur-runtime?为什么 Typescript 不需要 typescript-runtime,就像 traceur 需要 traceur-runtime 一样?
【发布时间】:2015-05-28 22:44:36
【问题描述】:

Typescript 和 Traceur 都将 ES6 编译为 ES5 对,那么 traceur-runtime 需要什么?其次,为什么没有 typescript-runtime?

PS:我读到 traceur-runtime 填充了“缺失”的功能,并且还提供了更多功能并提供了某些功能使用的辅助功能,但我不确定那是什么真正的意思

【问题讨论】:

    标签: typescript traceur


    【解决方案1】:

    其次,为什么没有 typescript-runtime

    它假定用户将自己添加他们需要的东西,例如如果您使用 Promise,它假定 您的运行时拥有它

    对于像类继承这样的其他东西,它提供了帮助器内联,例如:

    class Base{ }
    class Child extends Base { }
    

    生成(通知__extends):

    var __extends = this.__extends || function (d, b) {
        for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
        function __() { this.constructor = d; }
        __.prototype = b.prototype;
        d.prototype = new __();
    };
    var Base = (function () {
        function Base() {
        }
        return Base;
    })();
    var Child = (function (_super) {
        __extends(Child, _super);
        function Child() {
            _super.apply(this, arguments);
        }
        return Child;
    })(Base);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-13
      • 1970-01-01
      • 2017-10-22
      • 1970-01-01
      • 2022-08-10
      • 1970-01-01
      • 2017-10-21
      • 2019-03-09
      相关资源
      最近更新 更多