Wrong output order for single file compilation

Topics: General
Sep 11, 2013 at 6:43 PM
I have a project where I used to compile to multiple files, and everything worked fine. I decided to move to a single file output, and it started compiling classes in the wrong order.

There is no circular dependency, basically some hierarchy in different folders, something like this

\App <- app classes depends on Lib
\Scripts\Lib <- libraries written in typescript, depends on declaration files only
\Views\Name\View.ts <- view code, depends on App classes

TypeScript compiles all of them to a single file, but it orders the output incorrectly. It puts classes from "\App" before "\Script\Lib", but not all of them. It seems that some ordering is being done, but something messes it up before the final output.

I noticed that the output order changes depending on which file I change first. It also changes the order of the output if I move a file to another folder and fix the references, even if I don't change the actual hierarchy of classes.

It is erratic behavior, I couldn't find the exact pattern that causes it, but it is definitely happening.

Is anyone else seeing this behavior?
Sep 11, 2013 at 11:44 PM
Yes there are issues around single file output class ordering. There's a work item here: https://typescript.codeplex.com/workitem/913
Sep 12, 2013 at 10:28 PM
I'd like to note for the dev team that there are issues with regular inheritance, not only with circular references.

I saw paulb's comments that some things are by design, but this doesn't seem like it.

My code is quite simple, A extends B, C extends B, but depending on which folder the files are, they are compiled in the wrong order and this keeps changing depending on which file I change later.

This seems to happen only if you have classes in different directories, and makes it impossible to use single file output for anything other than samples.
Sep 14, 2013 at 2:43 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Sep 15, 2013 at 5:46 PM

Thanks for reporting, we need a little more information here.

Does this happen in Visual Studio with Compile on Save, or when doing a build? Does this happen when doing a command line compile? If so what is the exact command line you use?

Can you add this information to the workitem?