In my Angular 2 app, I have following code:
import { Observable } from 'rxjs/Rx';
import { Subscription } from '@angular-cli/ast-tools/node_modules/rxjs/Rx';
...
private broadcastDataSubject: BehaviorSubject<Event>;
...
let sub: Subscription = this.broadcastDataSubject.asObservable().subject(event).subscribe(() => this.bla());
Problem is in the last row, code will not complile because of:
"Type 'Subscription' is not assignable to type 'Subscription'. Two different types with this name exist, but they are unrelated."
I have same code in my second project and it runs without problem.
The problem was that I had 2 same imports:
import { Subscription } from '@angular-cli/ast-tools/node_modules/rxjs/Rx';
One in the component and one in service.
I was having the same issue until I saw that I was importing my Observable from:
import { Observable } from '@firebase/util';
I changed it to:
import { Observable } from 'rxjs/Observable';
and it was working fine.
I got this error when I misspelt Observable. In the import I wrote:
import { Observable } from 'rxjs/observable';
where as it should be
import { Observable } from 'rxjs/Observable';
P.S. this was for the version 5.2.11
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With