I'm updating all my angular forms to typed forms. I define it like follows:
readonly personForm: FormGroup<{
name: FormControl<string>
favorites: FormControl<string[] | null>
}>;
And I initialize it like:
this.personForm = this.fb.group({
name: this.fb.nonNullable.control("", Validators.required),
favorites: new FormControl({ value: [""], disabled: false})
});
Somewhere in the code I'm resetting the form once I get the data from the API. The "favorites" is a select from a list from another API method, let's call it food.
If this food list is empty, then
this.personForm.reset({
name: person.name,
favorites: {
value: person.favorites || [],
disabled: this.food && this.food.length < 1
}
});
Where person is the constant which contains my API data response.
On this favorites assignation I get a TS error:

So I'm guessing the way I'm defining the FormControl it's not correct at all. How do I have to define it?
valueanddisabledto your form control value of typestring[]. Maybe you wanted to assign thisvalueattribute to your form control (usingsetValue) and yourdisabledattribute to the form accordingly.ngOnInit. Let me update the code a bit. I have more fields, not just 2. But the only problem I get is with the disabled.