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

264
Visualizações
How to resolve Angular Error with async pipe?

I am currently experiencing a problem with angular, if i use a several pipe in addition to async pipe like that :

      <p>Mis à jour : {{ lastUpdate | async | date: 'yMMMMEEEEd' | uppercase }}</p>

the code can't compile and i have this error :

Error: src/app/app.component.html:5:39 - error TS2769: No overload matches this call. Overload 1 of 3, '(value: string | number | Date, format?: string | undefined, timezone?: string | undefined, locale?: string | undefined): string | null', gave the following error. Argument of type 'unknown' is not assignable to parameter of type 'string | number | Date'. Type 'unknown' is not assignable to type 'Date'. Overload 2 of 3, '(value: null | undefined, format?: string | undefined, timezone?: string | undefined, locale?: string | undefined): null', gave the following error. Argument of type 'unknown' is not assignable to parameter of type 'null | undefined'. Type 'unknown' is not assignable to type 'null'. Overload 3 of 3, '(value: string | number | Date | null | undefined, format?: string | undefined, timezone?: string | undefined, locale?: string | undefined): string | null', gave the following error. Argument of type 'unknown' is not assignable to parameter of type 'string | number | Date | null | undefined'. Type 'unknown' is not assignable to type 'Date'.

any idea where the problem may come from?

lastUpdate = new Promise((resolve, reject) => {
    const date = new Date();
    setTimeout(
        () => {
            resolve(date);
        }, 2000
    );
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You are creating a promise without specifying, which type the resolved value should have, therefore it is typed as unknown. However, the date pipe does not accept type unknown.

Add type Date to the promise like the following:

lastUpdate = new Promise<Date>( //...
about 4 years ago · Juan Pablo Isaza 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