title: Import TypeScript Module from a Uri
body: <p>Is it possible within TypeScript to import a module or reference a definition file from a uri?</p>
  
  <p>We are using RequireJS for our application and would like to serve some of our definition files and TypeScript (or generated JavaScript) files from a CDN rather than including them all directly in our projects.</p>
  
  <p><strong>Referencing Definition Files</strong><br>
  In TypeScript we can reference a definition file like this:</p>
  
  <pre><code>/// &lt;reference path="jquery-1.8.3.d.ts" /&gt;
  </code></pre>
  
  <p>However, what we would like to do is this:</p>
  
  <pre><code>/// &lt;reference path="https://github.com/borisyankov/DefinitelyTyped/raw/master/jquery/jquery-1.8.d.ts" /&gt;
  
  export class UsesSomethingFromJQuery {
  
      TestMethod(element: JQuery) {
          // Do something with the supplied element
      }
  
  }
  </code></pre>
  
  <p><em>NOTE: I'm not planning to use Boris' github link as the CDN. I used the link to demonstrate the concept.</em></p>
  
  <p><strong>Importing TypeScript Files</strong><br>
  We would also like to import modules from a common website, like this:</p>
  
  <pre><code>import OtherModule = module('http://some-internal-site/ts/other');
  
  export class UsesSomethingFromOther {
  
      TestMethod(c: OtherModule.TestClass) {
  
      }
  
  }
  </code></pre>
  
  <p>However, I get the error 'Invalid import path' when providing a uri for the module.</p>
  
  <p><strong>What We're Trying to Solve</strong><br>
  We have a library of TypeScript files that generate JavaScript for our controls, some REST service wrappers, and other utilities. We'd like to use these common controls in other web applications.</p>
  
  <p>When we have a TypeScript file that is specific to one of our web sites (hence not part of the common core) that relies upon classes defined within the common core, we would like to reference the dependency using a uri. Hence the question above.</p>
  
  <p>If these were simply JavaScript source files we would host them on an internal CDN and reference from there but with the TypeScript compilation step we run into a problem. Are we approaching this in the wrong way? Is there a better way?</p>