title: Extension methods in typescript (system)
body: <p>In my angular2 project I'm trying to extend the prototype of the <em>string</em> class using typescript.
  This is my code: </p>
  
  <pre><code>interface String 
  {
      startsWith(s:string);
      contains(s:string);
      containsOr(s1:string, s2:string);
  }
  
  String.prototype.startsWith = function (s:string):boolean {
      return this.indexOf (s) === 0;
  }
  String.prototype.contains = function (s:string):boolean {
      return this.indexOf(s) &gt; 1;
  }
  String.prototype.containsOr = function (s1:string, s2:string):boolean {
      return this.indexOf(s1) &gt; 1 || this.indexOf (s2) &gt; 1;
  }
  </code></pre>
  
  <p>With this code the project compiles (also the content assist of Visual Studio Code assists me) but at run-time I get a 'contains is not defined'.</p>
  
  <p>What I'm doing wrong?</p>
  
  <p>Thanks a lot</p>
  
  <p>PS: this is my tsconfig:</p>
  
  <pre><code>{
    "compilerOptions": {
      "target": "es5",
      "module": "system",
      "moduleResolution": "node",
      "sourceMap": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "removeComments": false,
      "noImplicitAny": false,
      "outDir": "wwwroot/app/source/"
    },
    "exclude": [
      "node_modules",
      "bower_components",
      "wwwroot",
      "typings/main",
      "typings/main.d.ts"
    ]
  }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I noticed that importing the <em>js</em> file in <em>index.html</em> it works, but I don't like this approach.</p>
  
  <pre><code>&lt;script src="app/source/utils/extensions.js"&gt;&lt;/script&gt;
  </code></pre>