Duplicate Type Typescript Declaration

I am having problems with duplicate ads like Typescript in the following case:

I have the following dependency tree for my application A:

A->@angular/http:2.3.1
A->B->@angular/http:2.3.1

Both A and B are managed by npm. After launch

npm install

the file system looks like this:

A/node_modules/
  @angular/http
  ...
  B/node_modules
     @angular/http

The problem is that there are now two types of declarations of @ angular / http types of type Response or Headers. And somehow the Typescript transporter seems unable to handle this - as a result, the following error message appears:

TS2453: T . . "" "". "" . "" . 'mayBeSetNormalizedName'.

, , hickup Typescript, .

- ? ? ?

+6
2

, , using A. (. ) :

import {Response, Headers} from '@angular/http';
+4

. .

  • UMD B. .
  • as any as TheRequiredObject . .

, b:

export class B{
    getSome(): Observable {
        return this.http.get('some_url');
    }
}

, a:

export class A{
    getSomeFromB: Observable{
        return B.getSome() as any as Observable;
    }
}
+1

Source: https://habr.com/ru/post/1015893/


All Articles