olov / ng-annotate

Add, remove and rebuild AngularJS dependency injection annotations
MIT License
2.03k stars 152 forks source link

ng-annotate does not recognize `Module.decorator`...? #181

Closed al-the-x closed 9 years ago

al-the-x commented 9 years ago

I can see from previous issues (#82 and #108) that decorator functions that don't belong to Angular are not decorated... Is the current behavior to annotate only $provider.decorator and not Module.decorator...?

gkalpak commented 9 years ago

:+1:

al-the-x commented 9 years ago

So is that a yes? I noted in a recent project that injectables chained after .decorator were also not decorated, e.g.

angular.module('module')
  .config(function($someProvider){
    // gets annotated
  })
  .decorator(function(someService){
    // not annotated
  })
  .controller('SomeController', function(){
    // also not annotated
  })
  // nothing else annotated

I worked around the problem by sticking the decorator at the end of the chain and using /* @ngInject */ comments in front of it.

gkalpak commented 9 years ago

It was not exactly a yes, rather a I've observed the same behaviour and would love to have this fixed, so that ngAnnotate will properly recognize angular.decorator() as well. (But I tried to be laconic :smile:)

olov commented 9 years ago

The current behavior is that ng-annotate only supports $provider.decorator. See the linked issues for further explanation of why.

gkalpak commented 9 years ago

@olov, I am not at all familiar with the inner workings of ngAnnotate, but wouldn't it be possible to differentiate Module's decorator from other decorators ?

al-the-x commented 9 years ago

Without doing some fairly complicated static analysis of the input, I'm not so sure. The previous issues I referenced point to some difficulty resolving the receiver of the decorator method as an actual module instance, so I assume there's no such analysis being done at the moment. All in all, probably not worth the effort. On Jul 17, 2015 4:44 PM, "Georgios Kalpakas" notifications@github.com wrote:

@olov https://github.com/olov, I am not at all familiar with the inner workings of ngAnnotate, but wouldn't it be possible to differentiate Module's decorator from other decorators ?

— Reply to this email directly or view it on GitHub https://github.com/olov/ng-annotate/issues/181#issuecomment-122408437.

readme42 commented 8 years ago

:+1: It would be great, if angular module's decorator would work!