I have array of objects. Each object inside array represents an html input field. I want to load different interface on the base of type property inside the field.
interface Field {
type: 'text' | 'radio';
name: string;
}
interface TextField {
placeholder: string;
}
interface RadioField {
values: {
value: string;
label: string;
}[];
}
const fields: Field[] = [
{
// How to make use of TextField interface here
type: 'text',
name: 'firstName',
}
]