How to convert these methods

Topics: General
Dec 9, 2012 at 5:24 PM

Hi

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, '');
});