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

386
Visualizações
Argument of type 'unknown[]' is not assignable to parameter of type > 'OperatorFunction

component.ts

initialize() method says

Argument of type 'unknown[]' is not assignable to parameter of type 'OperatorFunction<unknown[], unknown>'. Type 'unknown[]' provides no match for the signature '(source: Observable<unknown[]>): Observable'

alertsChanged$: Observable<AlertModel[]>;

private initialize(): void {
  

    this.alertsChanged$ = this.alertsService.getAlerts().pipe(
      map((res) => res), // here it returns the above error
      tap((res) => {
        
        this.setDataForFilters(res); //Argument of type 'unknown' is not assignable to parameter of type 'AlertModel[]'.  
       
      }),          
    );
  }

 private setDataForFilters(alerts: AlertModel[]): void {}

service.ts

 // no issues here

 getAlerts(): Observable<AlertModel[]> {
      return this.angularFireDatabase
      .list<AlertModel>(`groups/${this.groupId}/alerts`)
      .valueChanges()
      .pipe(
        map((res) => orderBy(res, ['timeStamp'], ['desc'])),
        first()
      );
  }

.html

 <app-alerts
    [alerts]="alertsChanged$ | async"
  ></app-alerts>

Please let me the issue here?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I found the issue here. It was a conflict with the Lodash map and RxJS map. i.e. VS code didn't import the RxJS map due to the Lodash map and it gave the above error due to that.

Since I need to use both on the same component I have done it like so.

import { finalize, tap, map } from 'rxjs/operators';

import { map as lodashMap } from 'lodash';
over 4 years ago · Santiago Trujillo Relatório

0

The same kind of error will come if we use the imports from 'rxjs' and "rxjs/operators" at the same time. In my case this was the code,

  this.anApiCall.getAdata(this.id)
  .pipe(map(res => this.dataUtil.parseToForm(this.id, res)),
    onErrorResumeNext(of(this.dataUtil.newForm(this.id))))
  .pipe(tap(frm => this.form = frm))
  .subscribe();     

I was using 'onErrorResumeNext' operator but unfortunately, IDE imported the function from 'rxjs' instead of rxjs/operators.

 import { onErrorResumeNext } from "rxjs"; // if the import is like this then you will get error like 'Argument of type 'Observable<YourType>' is not assignable to parameter of type 'OperatorFunction<unknown, unknown>'.'

So check the import is from 'rxjs/operators' or not. and change the import as

import { map, tap, onErrorResumeNext  } from "rxjs/operators";
over 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