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

$inject is not added on exported class when transforming to ES5 #35

Open
sarod opened this issue Nov 8, 2017 · 1 comment
Open

$inject is not added on exported class when transforming to ES5 #35

sarod opened this issue Nov 8, 2017 · 1 comment

Comments

@sarod
Copy link

sarod commented Nov 8, 2017

When using the following code angularjs-annotate fails to annotate the class if the class is transpiled to ES5

/*@ngInject*/
export class Broken {
  	constructor($q) {
    
    }  
}box chec

The problem can be reproduced on the demo page https://schmod.github.io/babel-plugin-angularjs-annotate/ with the transform checkbox checked

Note that this works fine if the class is not exported.

I found several alternative placement of the @ngInject that work.

export /*@ngInject*/ class Ok {
  	constructor($q) {
    
    }  
}

export class Ok2 {
  /*@ngInject*/	
  constructor($q) {
    
    }  
}

It 1 also works if I use an alias for export

/* @ngInject */
class MyControllerInternal {
  constructor($q) {}
}

export const MyController = MyControllerInternal;
@sarod sarod changed the title $inject is not added if controller class is exported $inject is not added on exported class when transforming to ES5 Nov 8, 2017
@superted17
Copy link

@sarod thanks for posting your findings. I've got the same issue, and your suggestion to use /@ngInject/ before the constructor sort of worked for me.

This got the plugin to actually run, but the place that it inserts the $inject statement wasn't right and caused problems at runtime.

I'll see if I can add some failing unit tests...

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

2 participants