File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -765,9 +765,14 @@ function judgeInjectArraySuspect(path, ctx) {
765765 addInjectArrayAfterPath ( node . params , opath , declaratorName ) ;
766766
767767 } else if ( isFunctionDeclarationWithArgs ( node ) ) {
768- // /*@ngInject */ function foo($scope) {}
769- addInjectArrayBeforePath ( node . params , path , node . id . name ) ;
770-
768+ if ( t . isExportDefaultDeclaration ( path . parent ) && ! node . id ) {
769+ // export default function(a) {}
770+ node . id = path . scope . generateUidIdentifier ( 'ngInjectExport' ) ;
771+ path . parentPath . insertBefore ( buildInjectExpression ( node . params , node . id . name ) ) ;
772+ } else {
773+ // /*@ngInject */ function foo($scope) {}
774+ addInjectArrayBeforePath ( node . params , path , node . id . name ) ;
775+ }
771776 } else if ( t . isExpressionStatement ( node ) && t . isAssignmentExpression ( node . expression ) &&
772777 isFunctionExpressionWithArgs ( node . expression . right ) && ! path . get ( "expression.right" ) . $seen ) {
773778 // /*@ngInject */ foo.bar[0] = function($scope) {}
Original file line number Diff line number Diff line change @@ -59,6 +59,23 @@ module.exports = {
5959 export default function svc(dep1){}
6060 `
6161 } ,
62+ {
63+ name : "exported anonymous function" ,
64+ explicit : true ,
65+ input : `
66+ export default function ($timeout) {
67+ 'ngInject';
68+ return 'foo';
69+ }
70+ ` ,
71+ expected : `
72+ _ngInjectExport.$inject = ['$timeout'];
73+ export default function _ngInjectExport($timeout) {
74+ 'ngInject';
75+ return 'foo';
76+ }
77+ `
78+ } ,
6279 {
6380 name : "annotated class" ,
6481 explicit : true ,
You can’t perform that action at this time.
0 commit comments