Description
TypeScript Version:
1.8.0
Code
I'm porting my ASP.NET MVC app platform (Serenity) which were using Saltaralle C# -> JS transpiler to TypeScript. Currently TS is an alternate option but hoping to make it primary soon, after resolving some issues.
Saltaralle and its predecessor Script# uses some code similar to TypeScript internal modules or namespaces. So it was natural for me to choose this model over more complicated AMD/CommonJS etc. modules, which is a bit overkill for web apps in my humble opinion. Also it is much easier to explain to novice users.
I'm using tsconfig.json with outFile option, and no "files" list, so all .ts files in all subfolders are included by default.
If you have A.ts:
namespace Some {
export class A {
}
}
and B.ts:
namespace Some {
export class B extends A {
}
}
I'd expect combined output.js file to have A defined before B, otherwise it would cause a javascript error.
But, sometimes this is true, sometimes opposite. I know that you'd suggest me to put /// references or put files in correct order in tsconfig.json files property, or use external modules, but this exactly what i'm trying to avoid. I've read among several issues reported here, and workarounds offered like these, but dependency order resolving shouldn't be the job of developer, compilers are specially made for this.
I'd handle these workarounds myself, for my own projects, but my targeted users (devs) usually don't have the skills to understand what this ordering is all about. They'll simply report a bug with details: "not working", and without looking at their output file, i can't even guess what it is really about.
I understand that in some edge cases this might be difficult, but please offer an option to perform topological sort on input files for basic cases like this, e.g. a class extends another, references it in a decorator argument etc.
Expected behavior:
I'd expect internal modules to be topologically sorted based on dependencies.
Actual behavior:
Sometimes it is not. Derived class outputted before base class.