使用AoT时"NgModule的提供程序无效"

men*_*fon 1 typescript angular2-aot angular

没有AoT一切正常.但是在切换加载器之后,我收到了这个错误并且不知道如何解决它,或者究竟是什么问题.

"/xxx/src/app/app.module.ts"中NgModule"AppModule"的提供程序无效 - 只允许提供者和类型的实例,得到:[/ logx /src /app/services/login.service.service中的LoggerService .ts,LocalXtorageService在/xxx/node_modules/angular-2-local-storage/dist/local-storage.service.d.ts,WindowsService在/xxx/src/app/services/window.service.ts,? null? ,...]

相关代码来自AppModule:

import CustomHttp from './services/custom-http.service';

...

@NgModule({

...

  providers: [
    LocalStorageService,
    WindowService,
    AuthService,
    LoggerService,
    CustomHttp,
    AuthTokenStore,
    AuthService,
    SchemaValidator,
    AuthInterceptor,
    DataService,
    ErrorHelper,
    FileUpload,
    {provide: ErrorHandler, useClass: LoggingErrorHandler},
    NonAngularDialogsHelper,
    ConfirmationService,
    SearchHelper,
    FormHelper,
    DebugHelper,
    PuxApplication,
    StoreUtils,
    TranslationHelper,
    MessagesService,
    CustomValidatorsService,
    GeolocationService,
    SavedSearchesService,
    LoggedInfoService,
    BeTranslate,
    CountryHelper,
    SuggestionGenerators,
    PrimeNgHelper,
    UrlHelper,
    DocumentClickService,
    NavigationHelper,
    BeErrorsInterceptor,
    DocumentService,
    ScrollHelper,
    LinkDialogHelper,
    HtmlUtilsService,
    RouterHelperService,
    StripeService,
    VatExamplesService,
    ContactInfoHelper,
    WizardHelper,
    PasswordChangingPagesHelper,
    LandingPageHelper,
    TrackingEventsHelper,
    RfoHelper,
    ReactiveFormsHelper,
    LiveChatService,

    CounterActions
  ]

...
Run Code Online (Sandbox Code Playgroud)

片段来自CustomHttp:

...

@Injectable()
export default class CustomHttp {

...

  constructor(private http: Http,
              loggerService: LoggerService) {
    this.logger = loggerService.createLogger('CustomHttp');
  }

...
Run Code Online (Sandbox Code Playgroud)

编辑1:根据请求添加整个提供程序数组.

men*_*fon 5

AoT编译器不是很聪明.原来它出于某种原因无法处理默认导入......

不工作:

import CustomHttp from './services/custom-http.service';
Run Code Online (Sandbox Code Playgroud)

工作:

import { CustomHttp } from './services/custom-http.service';
Run Code Online (Sandbox Code Playgroud)