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