我正在尝试将其添加到 .ts 文件的底部,但我在 VS2012 [under: if (!Object.construct) ] 中收到一个错误,即未定义构造和扩展。解决方案?
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//