New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Class used before its declaration" in the generated file #58
Comments
Why dont you use |
The problem I see here is that the output is erroneous by default. And it can be cumbersome to figure out and maintain the proper order in a situation with numerous interdependent classes. I kinda expected this framework to order types properly by itself. Is this out of the scope of the project? Were there attempts to sort it out automatically? |
It is out of scope of project because
So for now I'm not going to implement that. If you want to implement this feature - feel free to fork & PR. Otherwise please use |
If someone else comes upon this issue, here's one way to "pull all the base classes to the top" in a more or less universal manner:
May be quite far from perfect, it's only tested to cover my specific case. |
Thank you, Egor! But it would be much better if you post such kind of question to stackoverflow - more audience coverage there. I have marked your solution with "faq" label, but still not sure that someone can find it quickly. |
Thanks for the idea @yegorpetrov, the proposed solution is OK but the I made a bit more verbose version of the hierarchy enumeration with a Type dict like so:
... I tested this separately on three class files (Class1, Class2, Class3) from three different Namespaces like so:
And the tested order I get is:
So either way the Class1 should appear before Class2 which extends it in TypeScript so we shouldn't get the error of having a class used before its declaration, but unfortunately that is not the case. The output: |
@vmandic I think that's because you have separate namespaces. You can't expect the lower level order to override the higher level one automatically. |
RT. Connecting people. |
Basically, this:
I'm not sure if it's a bug, but I guess it shouldn't happen at least in the default configuration.
Here is the example from the screenshot:
reinforced_class_used_before_its_declaration.zip
The text was updated successfully, but these errors were encountered: