Let me preface my question by saying that I realize this is more of a generic StackOverflow question, but I'd like to get a response here, both because the versions of TypeScript and Node.js are known and for future reference.
I tried splitting my single script.ts file into three files - I've tried both the namespace approach and the module approach - but either compilation or execution fails. Neither the TypeScript handbook, StackOverflow nor Google helped me solve the problem. Does anyone have a step by step guide to split your script.ts file into multiple separate files?
[edit] These are the errors I get when I run my script with modules:
D:\Workspace SDK\CreateWS>node script.js
D:\Workspace SDK\CreateWS\momdata.ts:1
(function (exports, require, module, __filename, __dirname) { export class Entit
y {
^^^^^^
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\Workspace SDK\CreateWS\script.js:5:12)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
and
D:\Workspace SDK\CreateWS>node --harmony_modules script.js
D:\Workspace SDK\CreateWS\momdata.ts:1
(function (exports, require, module, __filename, __dirname) { export class Entit
y {
^^^^^^
SyntaxError: Unexpected token export
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\Workspace SDK\CreateWS\script.js:5:12)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
[Edit2] I solved my problem: I noticed in the error message that a .ts file was referenced. I manually edited the generated script.js files to point to the momdata.js file, instead of momdata.ts file. This then leads to another question: what should I do to automatically convert the line
import data = require("./momdata.ts");
to
import data = require("./momdata.js");
?