0

I was working on a project last year, it was using Angular 8. I resumed the project this year, I now am using Angular 13 to make the project more actual. I was stunned by the amount of errors it threw. Many of the code I used on the ngOnInit I had to change to the contructor, mainly property initialization highlighting FormGroup now I have to initialize it in the constructor otherwise I get a message saying that it was not initialized in the constructor. I cannot use the sysntax someObject["property"] because the string property may not be a property of someObject. I got a lot of other erros related to syntax. What happened since Angular 8. I am not "Javascript developer". I am not inside what is going on.

I am positive that want to use Angular 13 but. 5 versions is huge gap I am not complained. Is it true that since Angular 8 there were changes on syntax rule?

Diego Alves
  • 2,462
  • 3
  • 32
  • 65
  • I had this problem with ionic 3 to migrate to ionic 5. Sometimes it's easier to start a new app and adapt once you already have all the code practically ready – Diego Desenvolvedor Nov 15 '21 at 15:11
  • Thanks for the comments and answers. I was really surprised by those changes... in early versions changes 2,3,4 I didn't experience this. I am sure they made it for the best. – Diego Alves Nov 15 '21 at 15:34

2 Answers2

1

Seems like during some update, Angular's strict mode was activated. The compiler then requires a more strict syntax. You can get rid of those errors by setting "strict": false in tsconfig.json.

But the Angular team recommends to use strict mode for the following reasons:

Strict mode improves maintainability and helps you catch bugs ahead of time. Additionally, strict mode applications are easier to statically analyze and can help the ng update command refactor code more safely and precisely when you are updating to future versions of Angular.

JSON Derulo
  • 9,780
  • 7
  • 39
  • 56
0

I am positive that want to use Angular 13 but. 5 versions is huge gap I am not complained. Is it true that since Angular 8 there were changes on syntax rule?

Short answer: Yes.

Given the large amount of major updates you have to go through, I suggest to use the official update guide. It allows you to go through required changes step by step and tackle them one by one as they occur. I directly linked the guide from 8.0 to 13.0, however, I suggest you do this in smaller steps (8.0 -> 9.0; 9.0 -> 10.0 and so on). This will dramatically help you to see exactly what (obvious) changes you need to adjust your code for.

If you want an ever deeper dive you can read up on the official changelogs.

Philipp Meissner
  • 5,273
  • 5
  • 34
  • 59