将 ng2-translate 与 jhipster 一起使用,属性 'parser' 在类型 'TranslateService' 中是私有的,但在类型 'TranslateService' 中不是

using ng2-translate with jhipster, Property 'parser' is private in type 'TranslateService' but not in type 'TranslateService'

我正在使用 angular-cli 作为 Jhipster 的客户端,当我尝试构建我的项目时,我在翻译模块上遇到了问题,我尝试升级到 ngx-translate,但我仍然有同样的问题。

这是我得到的错误:

'TranslateService' 不可分配给 'TranslateService'.

类型的参数

共享-common.module.ts :

    import { NgModule, Sanitizer } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { TranslateService } from 'ng2-translate';
import { AlertService } from 'ng-jhipster';
import {
    CarcheckappSharedLibsModule,
    JhiLanguageHelper,
    FindLanguageFromKeyPipe,
    JhiAlertComponent,
    JhiAlertErrorComponent
} from './';

export function alertServiceProvider(sanitizer: Sanitizer,
                                     translateService: TranslateService) {
    // set below to true to make alerts look like toast
    const isToast = false;
    return new AlertService(sanitizer, isToast, translateService);
}

@NgModule({
    imports: [
        CarcheckappSharedLibsModule
    ],
    declarations: [
        FindLanguageFromKeyPipe,
        JhiAlertComponent,
        JhiAlertErrorComponent
    ],
    providers: [
        JhiLanguageHelper,
        {
            provide: AlertService,
            useFactory: alertServiceProvider,
            deps: [Sanitizer, TranslateService]
        },
        Title
    ],
    exports: [
        CarcheckappSharedLibsModule,
        FindLanguageFromKeyPipe,
        JhiAlertComponent,
        JhiAlertErrorComponent
    ]
})
export class CarcheckappSharedCommonModule {}

你用错包了。

import { TranslateService} from '@ngx-translate/core';

AlertService 期望 TranslateService 来自 @ngx-translate/core,您不能将其与另一个交换。 如果你想使用 ng2-translate 你必须创建你自己的 AlertService.