简体   繁体   English

打字稿Visual Studio 2015 ES5

[英]Typescript visual studio 2015 es5

We are using visual studio 2015, and have the following typescript :- 我们正在使用Visual Studio 2015,并具有以下打字稿:-

class Form extends TestBase {
constructor(obj, settings) {
super();
super.automap(this, obj, Object.assign({}, settings, { overrides: { Template: Template } }));
  }
}

Using the visual studio 2015 typescript compiler, this compils down to :- 使用visual studio 2015打字稿编译器,它编译为:-

class Form extends TestBase {
constructor(obj, settings) {
    super();
    super.automap(this, obj, Object.assign({}, settings, { overrides: {} }));
}
}

Which is fine, and works great in chrome, however, we would like this to also work in ie10 / ie11. 这很好,并且在chrome中效果很好,但是,我们希望它也可以在ie10 / ie11中工作。

i believe that we need to 'polyfill' this so that the js file generated is converted to es5. 我认为我们需要对此进行“ polyfill”处理,以便将生成的js文件转换为es5。

Is there currently anything in visual studio that can do this? Visual Studio中目前有什么可以做到这一点的吗? What is the best way for this conversion? 进行此转换的最佳方法是什么? or any samples? 或任何样品?

From TypeScript 2.1 you can use spread syntax: 在TypeScript 2.1中,您可以使用传播语法:

super.automap(this, obj, { ...settings, overrides: { Template: Template } } );

This will transpile into Object.assign , including polyfill. 这将转换为Object.assign ,包括polyfill。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM