It seems like the issue you're facing is related to the order in which your classes are being added to the compiled .js
file. I encountered a similar problem with Visual Studio where the single-file compilation feature caused complications for me as well.
Upon reviewing the compiled file, have you noticed any instances where a class is inheriting from a base class that hasn't been defined until later in the document? This could be leading to the unexpected behavior you're experiencing when the compilation is triggered by a save action.
It's strange that this behavior occurs only during a save operation - it could indicate some level of unpredictability in the compiler's output sequencing. Incremental compilation may play a role in this inconsistency.
To address this issue, you can utilize the <reference>
tag to specify that a certain class should be defined after another one in the compilation process.
For instance, by including a reference tag in a subclass declaration like this:
/// <reference path="./MyBaseClass" />
class MyClass extends MyBaseClass {
}
you can ensure that the subclass will come after its base class in the resulting compiled .js
file:
class MyBaseClass {
}