export interface CommonControls {
chosen: FormControl<boolean>;
}
export interface FormControlsOne extends CommonControls {
title: FormControl<string>;
cost: FormControl<string>;
}
export interface FormControlsTwo extends CommonControls {
arrangement: FormControl<number>;
genre: FormControl<string>;
info: FormControl<string>;
}
export type MainFormGroup<T extends CommonControls> = FormGroup<T>;
Why am I having trouble extending specific controls with common controls and using them in a type? There's an issue at FormGroup<T>
indicating
Type T does not satisfy the constraint
{ [K in keyof T]: AbstractControl<any, any>; }
I've come across suggestions online where they propose to use:
export interface CommonControls {
chosen: FormControl<boolean>;
[key: string]: AbstractControl<any, any>;
}
However, this allows for adding various controls to the FormGroup which defeats the purpose of having a strongly typed form.
Any guidance?