I’m trying to write a new package in Typescript and can’t figure out how to export a class for use in another package.
Here’s a part from my package.js:
Package.onUse(function (api) {
api.versionsFrom("1.10");
api.use(["typescript"], "server");
api.addFiles(["meteor-typescript-compiler.ts"], "server");
api.export(["MeteorTypescriptCompiler"], "server");
});
and the .ts file itself has:
export class MeteorTypescriptCompiler {
constructor() {
console.log("MeteorTypescriptCompiler constructor called");
}
...
}
If I then try to use MeteorTypescriptCompiler in another package, it is undefined and the code will crash.
If I instead use javascript in the package, it works just fine:
Package.onUse(function (api) {
api.versionsFrom("1.10");
api.use(["typescript"], "server");
api.addFiles(["meteor-typescript-compiler.js"], "server");
api.export(["MeteorTypescriptCompiler"], "server");
});
MeteorTypescriptCompiler = class MeteorTypescriptCompiler {
constructor() {
console.log("MeteorTypescriptCompiler constructor called");
}
I also tried using api.mainModule("meteor-typescript-compiler.ts", "server");
but that did not help.
I’m not sure the typescript even gets compiled for the package TBH but I did follow the instructions on https://atmospherejs.com/meteor/typescript