Skip to content
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

reference-following does not handle re-assigned variables #9

Open
schmod opened this issue Aug 4, 2016 · 0 comments
Open

reference-following does not handle re-assigned variables #9

schmod opened this issue Aug 4, 2016 · 0 comments

Comments

@schmod
Copy link
Owner

schmod commented Aug 4, 2016

We currently do not handle cases like this:

var ctrl = function(d){};
ctrl = function(e){}

var c1 = {
    controller: ctrl
}

ctrl = function(f){};

var c2 = {
    controller: ctrl, 
}

angular
    .module("myMod", [])
    .component("c1", c1)
    .component("c2", c2);

Output:

var ctrl = function(d){};
ctrl.$inject = ["d"];
ctrl = function(e){}

var c1 = {
    controller: ctrl
}

ctrl = function(f){};

var c2 = {
    controller: ctrl, 
}

angular
    .module("myMod", [])
    .component("c1", c1)
    .component("c2", c2);

Realistically, this will be difficult/impossible to infer statically, so it may not even be worth bothering to correct the test case above (which can be inferred statically).

Babel tells us that ctrl can not be treated like a constant, and it may be sufficient to simply print a warning whenever we try to follow a mutable reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant