我试图将此添加到.ts文件的底部,但是我在VS2012 [如果(!Object.construct)]构建并扩展了一个错误[]没有定义。解决方案?浏览器兼容性代码不能在ts中编译
if (!Object.construct) {
Object.construct = function(base) {
var instance = Object.create(base);
if (instance.initialize)
instance.initialize.apply(instance, [].slice.call(arguments, 1));
return instance;
}
}
if (!Object.extend) {
Object.extend = function(destination, source) {
for (var property in source) {
if (source.hasOwnProperty(property))
destination[property] = source[property];
}
return destination;
};
}
尝试这样做:
interface Object {
extend(destination, source): any;
construct(base): any;
}
class Game { etc//
真棒,这非常感谢 – Nikos 2013-03-25 16:39:39
嗯.. doesn' t似乎工作,仍然得到相同的错误 – Nikos 2013-03-25 17:16:51
你把接口放在一个模块里面吗?它适用于我,这是我能想到的唯一原因。 – 2013-03-25 17:30:44