While trying to validate my Angular application, I encountered the following error:
src/app/register/register.component.ts:45:39 - error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'AbstractControl[] | { [key: string]: AbstractControl; }'.
No index signature with a parameter of type 'string' was found on type 'AbstractControl[] | { [key: string]: AbstractControl; }'.
45 return control?.value === control?.parent?.controls[matchTo].value ? null : {isMatching: true}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The error originates from this method:
matchValues(matchTo: string): ValidatorFn {
return (control: AbstractControl) => {
return control?.value === control?.parent?.controls[matchTo].value ? null : {isMatching: true}
}
}
As a newbie in Angular and TypeScript, I am uncertain about how to resolve it. Any assistance or guidance would be greatly appreciated.