I have following methods in a common.js file. I get a compilation error on the first line when i include the “common.js” file into a typescript file.
How should I solve this ?
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, '');
});
Found it.
Just move the common.js file to a common.ts file. Then add the following code before the line which extends the ‘prototype’