title: Typescript - internal module cannot be imported - unexpected behavior
body: <p>I have 2 modules spread across 2 files as such:</p>
  
  <p>--App.Tools.Utils.ts</p>
  
  <pre><code>export interface ILogger {
      log: (msg: string) =&gt; void;
  }
  
  module App.Tools.Utils {     
  
  
      export class Logger implements ILogger { ... }
  
      export function someFunction(){ ... }
  }
  </code></pre>
  
  <p>then in the second file I import the module:</p>
  
  <p>--App.Routers.ts</p>
  
  <pre><code> /// &lt;reference path="App.Tools.Utils.ts" /&gt;
   module App.Routers { 
  
      import Utils = App.Tools.Utils;  //ERROR: A module cannot be aliased to a non-module type        
  
  }
  </code></pre>
  
  <p>I eventually figured out the solution was to move the ILogger interface INSIDE the App.Tools.Utils module to resolve the error. At first it made some sense, I figured the compiler wouldn't let me import the module because the Logger class implemented an interface that was not included in the module. To test, I moved the ILogger interface inside the module (error resolved) but then added an arbitrary interface right outside the module (one that is not used inside the module or anywhere) and the error returns..</p>
  
  <pre><code>export interface INeverUsed { } //generates same error
  
  module App.Tools.Utils {     
  
      export interface ILogger {
         log: (msg: string) =&gt; void;
      }
  
      export class Logger implements ILogger { ... }
  
      export function someFunction(){ ... }
  }
  </code></pre>
  
  <p>Looking at the generated JS, adding the interface outside the module generates a <code>define(["require", "exports"]</code> wrapper and that results in the error when trying to import the App.Tools.Utils module in the other file. Removing the interface removes the <code>define</code> wrapper and the resolves the error.</p>
  
  <p>Is it behavior expected? It makes no sense to me why a module is suddenly "closed" when I define an interface in the same file but outside the module, especially if that interface is not even used inside the module.</p>