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 'x' used before its declaration #17742
Comments
You will note that in the cases where you get an error, the compiled code will not run. |
Thank you for response, I can not find the relation between this issue and your response?!!! But I talked about incorrect 'error' when I compile!!!! I said there is a bug when I compile, It should be compiled without error, but I get 'incorrect' error!!!! |
@arashebrahimi Try adding There may be a "newer" way of doing that, but that let's the compiler know to compile Polygon.ts before ParallelogramF.ts when compiling into a single file |
I don't understand how this is expected behavior. The issue is that the child class isn't being recognized as such within the same namespace -- which should, in theory, eliminate the need to explicitly call out the reference. The compiler should know to compile the base class prior to any and all child classes. What I believe @arashebrahimi is stating is that it appears to be an alphabetization issue where child classes that come after the base class (in file name) alphabetically recognize the inheritance relationship, but those that come prior don't. I've found that this issue doesn't exist for interfaces, however. I'm able to reproduce this issue with TS 2.5.3 in Visual Studio Version 15.4.5. |
##
TypeScript Version: 2.4.1
Visual Studio Version: 14.0.25420.01 Update 3
File: ParallelogramF.ts
namespace JMath { export class ParallelogramF extends Polygon { ... } }
File: Polygon.ts
namespace JMath { export class Polygon { } }
Expected behavior:
Class Polygon must be known correctly.
Actual behavior:
Error Occurs: Class Polygon used before its declaration.
This occurs only when 'Combine JavaScript output into file' checkbox in project properties is checked and some 'xxx.js' file name is specified in front of it.
Solution:
1- When I change the name of file "ParallelogramF.ts" to "ZParallelogramF.ts" problem solves and it compiles correctly!!!!
2- When I uncheck 'Combine JavaScript output into file' checkbox it compiles correctly!!!!
The text was updated successfully, but these errors were encountered: