Argument of type 'Http' is not assignable to parameter of type 'Http' in Ionic ngx-translate


#1

I’m developing an Ionic 2 mobile app and want to use ngx-translate features. Following the tutorial, I’m importing necessary files in app module like this:

import {HttpClientModule, HttpClient} from ‘@angular/common/http’;
import {TranslateModule, TranslateLoader} from ‘@ngx-translate/core’;
import {TranslateHttpLoader} from ‘@ngx-translate/http-loader’;
import {AppComponent} from “./app.component”;
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, “./assets/i18n/”, “.json”);
}
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
})
],
bootstrap: [AppComponent]
})
export class AppModule { }

which gives the error

Argument of type ‘HttpClient’ is not assignable to parameter of type ‘Http’. Property ‘_backend’ is missing in type ‘HttpClient’.
how can i solve this help me soon…

and this is my project info:

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.1.8
Cordova Platforms  : android 7.0.0
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v6.11.1
npm               : 3.10.10
OS                : Windows 10

Environment Variables:

ANDROID_HOME : C:\Sdk

Misc:

backend : legacy

#2

Different versions of ngx-translate deal with Http and HttpClient and you are blindly mixing them up. Read the official documentation.