When I'm validating in my angular app I'm facing this 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}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is the method the error is coming from:
matchValues(matchTo: string): ValidatorFn {
return (control: AbstractControl) => {
return control?.value === control?.parent?.controls[matchTo].value ? null : {isMatching: true}
}
}
I'm just starting angular and TypeScript and I don't know how to fix it. Any help would be appreciated.