I'm talking about:
class MyAction {
}
class MyActionEdit extends MyActionNew { // <-- error pointing here
}
class MyActionNew extends MyAction {
}
I'm getting the following error: Uncaught ReferenceError: Cannot access 'MyActionNew' before initialization.
I'm not creating an instance, before all js is loaded. So I don't understand, why hoisting is not working here. The problem is: I cannot change the order of the class definitions (they are loaded from various files and combined to one big script - 3 combined files in this example).
I've already read this and many other questions, but none did answer my question.
This here is working for example:
class MyAction {
}
let test: MyActionNew = new MyActionNew(); // <- Hoisting works here
class MyActionEdit extends MyAction {
}
class MyActionNew extends MyAction {
}
How can I deal with this? I don't know if this helps, but I'm using typescript to generate the javascript files. May be there is something?
Related: Typescript class: will class be hoisted when I use two classes?
I've read all question with the tag "hoisting" here on stackoverflow, but did not find an answer.