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

Configuration block with strictDi #136

Open
nero120 opened this issue May 29, 2020 · 1 comment
Open

Configuration block with strictDi #136

nero120 opened this issue May 29, 2020 · 1 comment

Comments

@nero120
Copy link

nero120 commented May 29, 2020

Thank you for this library, it's working great except I have one issue that I just can't figure out. I'm defining a configuration block in a module and need to inject a provider, and I have strictDi enabled:

@NgModule({
  id: 'AppModule'
})
export default class AppModule {
  static config($compileProvider: ng.ICompileProvider) {
    $compileProvider.debugInfoEnabled(false);
  }
}

Obviously I get an error if I try to run this as-is:

Error: [$injector:strictdi] config is not using explicit annotation and cannot be invoked in strict mode

So my question is how can I annotate this function explicitly if I'm using the @NgModule decorator? Also worth mentioning, I am not use any 'ng-annotate' fork since I couldn't get it to work so for now I'm defining $inject to support strictDi for my components, but obviously I can't do the same for the config function. Any ideas?

@MartijnWelker
Copy link

You could use inline array annotation. Unfortunately the NgModule is incorrectly typed so typescript will complain. You could make a fork and fix the type or fix it with a ts-ignore (not recommended).

@NgModule({
  id: 'AppModule'
})
export default class AppModule {
  static config = ['$compileProvider', ($compileProvider: ng.ICompileProvider) {
    $compileProvider.debugInfoEnabled(false);
  }]
}

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