Property '...' has no initializer and is not definitely assigned in the constructor
Just go to tsconfig.json and set
"strictPropertyInitialization": false
to get rid of the compilation error.
Otherwise you need to initialize all your variables which is a little bit annoying
I think you are using the latest version of TypeScript. Please see the section "Strict Class Initialization" in the link
.
There are two ways to fix this:
A. If you are using VSCode you need to change the TS version that the editor use.
B. Just initialize the array when you declare it inside the constructor,
makes: any[] = [];constructor(private makeService: MakeService) { // Initialization inside the constructor this.makes = [];}
It is because TypeScript 2.7 includes a strict class checking where all the properties should be initialized in the constructor. A workaround is to add the !
as a postfix to the variable name:
makes!: any[];