lephyrus / ngx-translate-messageformat-compiler

Advanced pluralization (and more) for ngx-translate, using standard ICU syntax which is compiled with the help of messageformat.js.
MIT License
93 stars 30 forks source link

AoT Warning: Can't resolve all parameters for TranslateMessageFormatCompiler #2

Closed B4nan closed 7 years ago

B4nan commented 7 years ago

When building/serving angular-cli app (cli 1.4.4, angular 4.4.4) with AoT compilation enabled ($ ng serve --aot), there is a warning:

Warning: Can't resolve all parameters for TranslateMessageFormatCompiler in 
/path/to/app/node_modules/ngx-translate-messageformat-compiler/src/translate-message-format-compiler.d.ts: (?). 
This will become an error in Angular v5.x

Its probably connected to TranslateMessageFormatCompiler constructor definition.

I am using the service like this:


export function translateCompilerFactory() {
  return new TranslateMessageFormatCompiler(new MessageFormat());
}

@NgModule({
  imports: [
    TranslateModule.forRoot({
      compiler: {
        provide: TranslateCompiler,
        useFactory: translateCompilerFactory,
      }
    }),
  ],
})
export class AppModule { }
B4nan commented 7 years ago

I did a little digging and found similar issues, looks like all you need to do to fix this is to remove @Injectable decorator from TranslateMessageFormatCompiler.

Will send PR in a minute.