I searched in Google/Github/Stackoverflow about this error but I am not able to fix this. I hope someone can help with a fix or suggestion
I have updated Angular project from v9 to v10, and after the update i got errors like the followwing, in a couple of modules.
Property 'searchParameters' is used before its initialization.
address: this.searchParameters?.address,
And the code in short:
export interface PartnerSearchParameters {
name?: string;
code?: string;
address?: string;
taxRegNumber?: string;
}
@Component({
selector: 'app-partner-search-list',
templateUrl: './partner-search-list.component.html',
styleUrls: ['./partner-search-list.component.scss']
})
export class PartnerSearchListComponent implements OnInit, AfterViewInit {
searchParameters: PartnerSearchParameters;
modelMainFilters = {
address: this.searchParameters?.address,
code: this.searchParameters?.code,
name: this.searchParameters?.name
taxRegNumber: this.searchParameters?.taxRegNumber ,
};
constructor(...){}
ngOnInit(): void {...}
...
}
The searchParameters is defined before the modelMainFilters, where i want to use ..
So I don’t understand at all where I should define it to be good.
Any suggestion?