Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Errors after migration to angular 12

I am gettings errors everywhere after I migrated to angular 12 from angular 8.
By the way I did not get any error when migrating from 8 to 9, neither from 9 to 10, nor from 10 to 11.

Here is an example of error I get:

export interface HistoriqueStatutModel {
  userId: string;
  date: Date;
  statutCible: string;
  commentaire?: string;
  montantFacture?: number;
}

export interface CommentaireModel {
  message: string;
  date: Date;
  createdBy: string;
}

--- 

public listeStatut: Array<HistoriqueStatutModel | CommentaireModel>;

---

 <li *ngFor="let statut of listeStatut;">
    {{statut.message}}
 </li>

I get this error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

error TS2339: Property 'message' does not exist on type 'HistoriqueStatutModel | CommentaireModel'.
  Property 'message' does not exist on type 'HistoriqueStatutModel'.
 {{statut.message}}

Any idea ?

>Solution :

Angular 12 was the first version that had template type checking set to strict by default, that’s why you’re only now seeing these errors.

You can turn this off in your TypeScript configuration file by setting the strictTemplates flag to false.

Of course, it would be better to perform proper type checking in your code instead.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading