NTVS = Node Tools for Visual Studio
I created a new project with the server.js as main file. Then created several classes, each one in their file. All those files are referenced in a references.ts file.
All files contain a reference to references.ts.
However, my project does not run. It says that some classes does not exists.
So I tick the "Combine Javascript output into file" but the code from server.ts is not appended to the resulting file (all classes are there tough).
How could I use internal references ?
Edit: Here are the files I use
server.ts
/// <reference path="references.ts"/>
import http = require('http');
var html = new HtmlElement('html');
...
Classes/HtmlElement.ts
class HtmlElement {
tag: string;
attributes: Array<HtmlAttribute>;
childrens: Array<HtmlElement>;
parent: HtmlElement;
text: string;
...
references.ts
/// <reference path="Scripts/typings/node/node.d.ts" />
/// <reference path="Classes/HtmlElement.ts" />
If compiling without combine option this is the output of node.js window :
debugger listening on port 5858
C:\Zdisk\Projets\14 08 - QCM\NodeJsTypeScript1\ServerApp\server.js:5
var html = new HtmlElement('html');
^
ReferenceError: HtmlElement is not defined
at Object.<anonymous (C:\Projects\NodeJsTypeScript1\Server
App\server.js:5:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain [as _onTimeout] (module.js:497:10)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
Press any key to continue...
If I use the combine option, nothing happends because the resulting file contain only classes declaration.
The "Combine Javascript output into file" option does not work for files containing the import directive.
You can replace
by
Then the server.ts will be combined and everything works fine.
You could now create one file per class and instanciate thoses using
var instance=new MyClass();
Wich is a much more convenient syntax in my own opinion.