I have a question trying to figure out what the problem is. I created my own Http class, ExtendHttp, which extends the Angular2 Http class and packs it as an npm module. It compiles and tests the scripts executed within the project, but when I import it into another project using the npm module, it will give an error message:
severity: error message: "Argument of type" ConnectionBackend "- is not assigned to the parameter of type" ConnectionBackend ". Views are not compatible with the createConnection property. Type '(request: any) => Connection' is not assigned to the type '(request: any) => Connection '. Two different types with this name exist, but they are not connected. A connection type is not assigned to a connection type. There are two different types with this name, but they are not connected with each other. Property request types are incompatible. Request type “not assigned to the type“ Request. ”There are two different types with this name, but they are not related to friend. Types of property headers are incompatible. The type "Headers" is not assigned to the type "Headers. "There are two different types with this name, but they are not related to each other. The types have separate private property declarations" mayBeSetNormalizedName ". At: '35, 42 'source:' ts'
This is my custom Http class:
@Injectable()
export class ExtendedHttp extends Http {
private logger: Logger;
constructor(_backend: ConnectionBackend, _defaultOptions: RequestOptions,
private config: ApplicationConfiguration,
private evtsrv: EventService) {
super(_backend, _defaultOptions);
this.logger = new Logger(config.getLoggerConfig());
}
...
}
This is how I use it in another project:
@NgModule()
export class CoreModule {
static forRoot(authzrule: AuthzRule[]): ModuleWithProviders {
return {
ngModule: CoreModule,
providers: [
{ provide: UserSessionStorageService, useClass: UserSessionStorageService },
{
provide: Http,
useFactory: (xhrBackend: ConnectionBackend, requestOptions: RequestOptions,
config: ApplicationConfiguration, evtservice: EventService) =>
new ExtendedHttp(xhrBackend, requestOptions, config, evtservice),
deps: [ConnectionBackend, RequestOptions, ApplicationConfiguration, EventService]
},