olov / ng-annotate

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

Typescript class with @ngInject and with a method inside with @ngInject #221

Closed andreigabreanu closed 8 years ago

andreigabreanu commented 8 years ago

Hi,

This seems to be broken with 1.2.0. When you have a TS class which extends another class, but also you have a method which has "ngInject" it will move all nginject declarations after the extends but before the method ones as well.

The generated error and code is :

TypeError: Cannot set property '$inject' of undefined

var Foo = (function (_super) {
        __extends(Foo, _super);
        /**
         * @ngInject
         * @param props
         * @param translate
         */
        Foo.$inject = ["props", "translate"];
        Foo.onEnter.$inject = ["callback"];
            ....

        /**
         * @ngInject
         * @param callback
         */
        Foo.onEnter = function (callback) {
            callback();
        };
});
olov commented 8 years ago

Thanks for the report! Fixed in 1.2.1.