When submitting a form contained within a FormGroup
instance, I need to assign the filled values to an object created based on the interface schema. However, attempting to do this directly results in the following error:
ERROR in src/app/modules/objects/object-form/object-form-components/object-information/object-information.component.ts(97,9): error TS2322: Type '{ title: any; type_id: any; basises: any; problems: any; material_id: any; ' is not assignable to type 'ObjectFormComponent'. Object literal may only specify known properties, and 'title' does not exist in type 'ObjectFormComponent'.
const controls = this.informationForm.controls;
export interface ObjectCreateRequest {
title: string;
type_id: string;
problems: string[];
material_id: string;
}
const request: ObjectCreateRequest = {
title: controls.title.value,
type_id: controls.type.value.id,
problems: controls.problems.value.map(item => item.id),
material_id: (controls.material.value ? controls.material.value.id : null)
};
All controls within the form have any
types which is invalid for the interface. How can I address this issue?