title: Mixing TypeScript and Meteor - Classes across multiple files
body: <p>Apologies for any incorrect terminology. For those not familiar with Meteor, <a href="https://stackoverflow.com/questions/10693113/how-do-i-change-the-order-in-which-meteor-loads-javascript-files">it has a well-defined order of script loading</a>. I'm trying to create many <code>*.ts</code> files containing a class, like you'd see in C#'s <code>*.cs</code> files. I want to reference these <code>*.ts</code> files between each other, and ultimately from a <code>main.ts</code>.</p>
  
  <p>Compiling Car.ts:</p>
  
  <pre><code>class Car {
     constructor(public age: number) { }
  }
  </code></pre>
  
  <p>Generates Car.js:</p>
  
  <pre><code>var Car = (function () {
      function Car(age) {
          this.age = age;
      }
      return Car;
  })();
  </code></pre>
  
  <p>With Meteor, I want the following output:</p>
  
  <pre><code>Car = (function () {
      function Car(age) {
          this.age = age;
      }
      return Car;
  })();
  </code></pre>
  
  <p>So that Car can be referenced from another file, main.ts:</p>
  
  <pre><code>/// &lt;reference path="car.ts"/&gt;
  Meteor.startup(function () {
      console.log(Car); // Hopefully prints [Function: Car]
      var a: Car = null; // Compiles
  });
  </code></pre>
  
  <p>I can get close by modifying Car.ts:</p>
  
  <pre><code>declare var Car;
  
  class Car_ {
     constructor(public age: number) {}
  }
  
  Car = Car_;
  </code></pre>
  
  <p>But this produces a kludgy output:</p>
  
  <pre><code>var Car_ = (function () {
      function Car_(age) {
          this.age = age;
      }
      return Car_;
  })();
  Car = Car_;
  </code></pre>
  
  <p>And necessitates a kludgy main.ts:</p>
  
  <pre><code>/// &lt;reference path="car.ts"/&gt;
  Meteor.startup(function () {
      console.log(Car); // Prints [Function: Car_]
      var a: Car_ = new Car(); // Yuck!
  });
  </code></pre>
  
  <p>Any advice? I might be treating this like too much like a C# application. </p>