Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

263
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda