I am trying to add an additional method to Angular's FormGroup class which will set the state of the group + set error state from the server.
I have the following code in a form-helper.ts file in my Angular4 app.
import { FormGroup } from '@angular/forms';
export interface FormGroup {
setValueAndErrors(state: any, memberErrors: any);
}
FormGroup.prototype.setValueAndErrors = (state: any, memberErrors: any) => {
this.setValue(state);
// do some stuff with the memberErrors parameter
}
But the compiler throws an error on the FormGroup.prototype.setValueAndErrors line.
ERROR in C:/dev/AppName/AppName-Client/src/app/shared/utils/form-helper.ts (3,21): Property 'setValueAndErrors' does not exist on type 'FormGroup'.
thisis not going to be what you expect in that arrow function.