Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
Angular 2: Two different types with this name exist

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.

about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

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.

about 4 years ago · Santiago Trujillo Relatório

0

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.

about 4 years ago · Santiago Trujillo Relatório

0

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

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda