我在 common.js 文件中有以下方法。当我将“common.js”文件包含到打字稿文件中时,第一行出现编译错误。
我应该如何解决这个问题?
Function.prototype.method = function (name, func) {
///<summary>
///Create a new method if it not ready exists
///</summary>
if (!this.prototype[name]) {
this.prototype[name] = func;
return this;
}
};
String.method('trim', function () {
return this.replace(/^\s|\s+$/g, '');
});