title: TypeScript declare module
body: <p>I want to create local <strong>modules</strong> in my TypeScript (<em>with Angular 2</em>) app and then simple reference to any file with importing module like <code>myApp/components</code>, <code>myApp/pipes</code> etc., not using relative path (<em>../../../MyComponent</em>) as I have to do now. </p>
  
  <p>For instance, Angular 2 can be used like this. (<em>And I haven't found how they make it</em>)</p>
  
  <pre><code>import {Component} from 'angular2/core';
  </code></pre>
  
  <p>How can I achieve this behavior?</p>
  
  <hr>
  
  <p>I did some files like <code>components.ts</code>, <code>templates.ts</code> etc. where I export files from current section:</p>
  
  <pre><code>export * from './menu/item';
  export * from './menu/logo';
  export * from './article/article';
  export * from './article/sidebar';
  </code></pre>
  
  <p>... and then I have one main file <code>myApp.ts</code> where I declare modules like so:</p>
  
  <pre><code>declare module 'myapp/components' {
      export * from './application/components';
  }
  
  declare module 'myapp/templates' {
      export * from './application/templates';
  }
  </code></pre>
  
  <p>But this file doesn't generate anything so TS build tells me errors like <code>...file_path...(4,9): error TS2305: Module ''myapp/components'' has no exported member 'AlfaBeta'.
  </code></p>
  
  <p>Btw. my <code>tsconfig.json</code> looks like this:</p>
  
  <pre><code>{
      "compilerOptions": {
          "target": "ES5",
          "module": "system",
          "moduleResolution": "node",
          "sourceMap": true,
          "emitDecoratorMetadata": true,
          "experimentalDecorators": true,
          "removeComments": false,
          "noImplicitAny": false
      },
      "exclude": [
          "node_modules"
      ]
  }
  </code></pre>