How to extend String Prototype and use it next, in Typescript? : <p>I am extending String prototype chain with a new method but when I try to use it it throws me an error: <code>property 'padZero' does not exist on type 'string'</code>. Could anyone solve this for me?</p>

<p>The code is below. You can also see the same error in Typescript Playground.</p>

<pre><code>interface NumberConstructor {
    padZero(length: number);
}
interface StringConstructor {
    padZero(length: number): string;
}
String.padZero = (length: number) =&gt; {
    var s = this;
    while (s.length &lt; length) {
      s = '0' + s;
    }
    return s;
};
Number.padZero = function (length) {
    return String(this).padZero(length);
}
</code></pre>
