Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!