{"action":"created","issue":{"url":"https://api.github.com/repos/olov/ng-annotate/issues/184","labels_url":"https://api.github.com/repos/olov/ng-annotate/issues/184/labels{/name}","comments_url":"https://api.github.com/repos/olov/ng-annotate/issues/184/comments","events_url":"https://api.github.com/repos/olov/ng-annotate/issues/184/events","html_url":"https://github.com/olov/ng-annotate/issues/184","id":95726480,"number":184,"title":"ES6 Babel transpiling issue with /*@ngInject*/","user":{"login":"m3fawner","id":4428322,"avatar_url":"https://avatars.githubusercontent.com/u/4428322?v=3","gravatar_id":"","url":"https://api.github.com/users/m3fawner","html_url":"https://github.com/m3fawner","followers_url":"https://api.github.com/users/m3fawner/followers","following_url":"https://api.github.com/users/m3fawner/following{/other_user}","gists_url":"https://api.github.com/users/m3fawner/gists{/gist_id}","starred_url":"https://api.github.com/users/m3fawner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3fawner/subscriptions","organizations_url":"https://api.github.com/users/m3fawner/orgs","repos_url":"https://api.github.com/users/m3fawner/repos","events_url":"https://api.github.com/users/m3fawner/events{/privacy}","received_events_url":"https://api.github.com/users/m3fawner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-17T19:25:37Z","updated_at":"2015-07-17T19:47:13Z","closed_at":null,"body":"I have implemented classes in a way that allows me to continue to have variables/functions scoped to the class, and the class only, and that's causing ngAnnotate issues. I have my controllers declared as such in the source:\r\n\r\n```javascript\r\n'use strict';\r\nlet AppCtrl;\r\n(() => {\r\n    let vm, UserProfile, ModalService, ErrorService;\r\n    AppCtrl = class {\r\n        /*@ngInject*/\r\n        constructor(_UserProfile_, _ModalService_, _ErrorService_) {\r\n            vm = this;\r\n            [UserProfile, ModalService, ErrorService] = arguments;\r\n            init();\r\n\r\n            function init() {\r\n                vm.openMarketingModal = ModalService.openMarketingModal;\r\n                vm.errors = ErrorService.errors;\r\n                vm.whiteList = ['/cmc-rest/', '/myu/', '/ebz/'];\r\n                vm.supportedLanguages = [{\r\n                    label: 'English',\r\n                    locale: 'en_US'\r\n                }, {\r\n                    label: 'Español',\r\n                    locale: 'es_ES'\r\n                }];\r\n                vm.selectedLanguage = vm.supportedLanguages[0];\r\n                UserProfile.getUserProfile()\r\n                    .then((data) => {\r\n                              vm.userData = data;\r\n                    });\r\n            }\r\n        }\r\n    };\r\n})();\r\nangular.module('myApp')\r\n    .controller('AppCtrl', AppCtrl);\r\n```\r\n\r\nFrom what I've seen, the /*@ngInject*/ comment goes where I have it (just above the constructor). When it gets transpiled into ES5 using babel, we get the following:\r\n\r\n```javascript\r\n'use strict';\r\nvar _slice = Array.prototype.slice;\r\n\r\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }\r\n\r\nvar AppCtrl = undefined;\r\n(function () {\r\n    var vm = undefined,\r\n        UserProfile = undefined,\r\n        ModalService = undefined,\r\n        ErrorService = undefined;\r\n    AppCtrl = (function () {\r\n        /*@ngInject*/\r\n\r\n        function _class(_UserProfile_, _ModalService_, _ErrorService_) {\r\n            _classCallCheck(this, _class);\r\n\r\n            vm = this;\r\n\r\n            var _arguments = _slice.call(arguments);\r\n\r\n            UserProfile = _arguments[0];\r\n            ModalService = _arguments[1];\r\n            ErrorService = _arguments[2];\r\n\r\n            init();\r\n\r\n            function init() {\r\n                vm.openMarketingModal = ModalService.openMarketingModal;\r\n                vm.errors = ErrorService.errors;\r\n                vm.whiteList = ['/cmc-rest/', '/myu/', '/ebz/'];\r\n                vm.supportedLanguages = [{\r\n                    label: 'English',\r\n                    locale: 'en_US'\r\n                }, {\r\n                    label: 'Español',\r\n                    locale: 'es_ES'\r\n                }];\r\n                vm.selectedLanguage = vm.supportedLanguages[0];\r\n                UserProfile.getUserProfile().then(function (data) {\r\n                   vm.userData = data;\r\n                });\r\n            }\r\n        }\r\n\r\n        return _class;\r\n    })();\r\n})();\r\nangular.module('myApp').controller('AppCtrl', AppCtrl);\r\n//# sourceMappingURL=app.controller.es5.js.map\r\n```\r\n\r\nAs you can see, the comment is in the correct spot still, but I get the following from my ngAnnotate task:\r\n```\r\nGenerating \"target/src/app/app.controller.es5.js\" from: \"target/src/app/app.controller.es5.js\"...ERROR\r\n>> error: TypeError: Cannot read property 'type' of undefined\r\nWarning: Task \"ngAnnotate:target\" failed. Use --force to continue.\r\n\r\nAborted due to warnings.\r\n```\r\n\r\nIf I rewrite the same class to look as such:\r\n\r\n```javascript\r\n'use strict';\r\nlet vm, UserProfile, ModalService, ErrorService;\r\nclass AppCtrl {\r\n    /*@ngInject*/\r\n    constructor(_UserProfile_, _ModalService_, _ErrorService_) {\r\n        vm = this;\r\n        [UserProfile, ModalService, ErrorService] = arguments;\r\n        init();\r\n\r\n        function init() {\r\n            vm.openMarketingModal = ModalService.openMarketingModal;\r\n            vm.errors = ErrorService.errors;\r\n            vm.whiteList = ['/cmc-rest/', '/myu/', '/ebz/'];\r\n            vm.supportedLanguages = [{\r\n                label: 'English',\r\n                locale: 'en_US'\r\n            }, {\r\n                label: 'Español',\r\n                locale: 'es_ES'\r\n            }];\r\n            vm.selectedLanguage = vm.supportedLanguages[0];\r\n            UserProfile.getUserProfile()\r\n                .then((data) => {\r\n                     vm.userData = data;\r\n                });\r\n        }\r\n    }\r\n}\r\nangular.module('myApp')\r\n    .controller('AppCtrl', AppCtrl);\r\n```\r\n\r\nEverything works fine, transpiling and ngAnnotate included. Any help would be extremely appreciated!"},"comment":{"url":"https://api.github.com/repos/olov/ng-annotate/issues/comments/122391896","html_url":"https://github.com/olov/ng-annotate/issues/184#issuecomment-122391896","issue_url":"https://api.github.com/repos/olov/ng-annotate/issues/184","id":122391896,"user":{"login":"olov","id":19247,"avatar_url":"https://avatars.githubusercontent.com/u/19247?v=3","gravatar_id":"","url":"https://api.github.com/users/olov","html_url":"https://github.com/olov","followers_url":"https://api.github.com/users/olov/followers","following_url":"https://api.github.com/users/olov/following{/other_user}","gists_url":"https://api.github.com/users/olov/gists{/gist_id}","starred_url":"https://api.github.com/users/olov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olov/subscriptions","organizations_url":"https://api.github.com/users/olov/orgs","repos_url":"https://api.github.com/users/olov/repos","events_url":"https://api.github.com/users/olov/events{/privacy}","received_events_url":"https://api.github.com/users/olov/received_events","type":"User","site_admin":false},"created_at":"2015-07-17T19:47:13Z","updated_at":"2015-07-17T19:47:13Z","body":"Thanks for your test case. This is a bug, ng-annotate should not crash that way on any input code. I'll look into it."}}