-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Un used variable is emmitted while transpiling enums. #4620
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
Comments
It´s nccessary to use State enum. Consider this example: TS
JAVASCRIPT
But I don´t understand this:
JS could be:
Instead of :
|
Yep your code looks perfectly fine and reasonable when using the State enum at the same file. But In my case I am using State enum in different files. which means the only enum related code is there. So
is unused one and also I am using Visual Studio Code which also complain the same. Use case seniorio in another file after importing the enum (I am using backbone model)
In my point of view.
should be there iff the State enum is used in same file. Thanks |
@madhurakhal I don't think removing unused declarations is something we're aiming to achieve - a namespace is certainly consumable by others if any other code occurs after this. This is an optimization that linters and/or optimizers could work on.
The idea point is that enums merge with prior declarations (hence the namespace E {
export const C = 20;
}
enum E {
A = 10,
B = 20,
} |
@rbuckton is this fixed in the transforms branch? |
Accepting PRs for the transforms branch / 2.1 to make the emit the same as the namespace emit code (declare a var above the IIFE, then assign to the var in the IIFE arguments) |
TypeScript code
Compled JavaScript Code.
I am using TypeScript version 1.5.3
The text was updated successfully, but these errors were encountered: