Can't compile two files under same namespace(module) into one js file


if you have multiple files under same namespace(module), you will not be able to compile two ts file into one js file.

for example, I have two files: Bar.ts & Bars.ts, I want to put two class under same namespace(module),
those two files can be compiled successfully into two separate js files, but will get compile error if I want to compile two ts files into one js file.
I attached the solution, you can check it with the solution. I updated the project file to compile ts files into one js file for Debug mode.
you will get a compile error if you compile in Debug mode.
it compiles if you compile in Release mode.

file attachments

Closed May 10, 2013 at 8:09 PM by danquirk
This is by design at the moment. If you want multiple files to contribute to the same output .js file then you can use the --out compiler switch and internal modules. That is, don't use import and export in your individual files, just use triple slash references for the necessary dependencies, then compile with --out and specify the .js you want everything concatenated into.

For creating a single external module from multiple source .ts files we have an outstanding design issue we're hoping to address.


jaygj2010 wrote May 8, 2013 at 9:19 AM

Yes ,I have met the same problem, I hope module keyword in typescript have the same function with C# namespace, So I can separate some Class into different typescript file but with the same namespace. that will be great.