I have some data I create manually:
const fields = [{ id: 'myId', value: '', type: 'text' }, { id: 'myId2', value: '', type: 'select' }]
OR
const fields = { myId: { value: '', type: 'text' }, myId2: { value: '', type: 'select' } }
I would like to build an interface like:
type Out = { myId: string; myId2: CustomType }
string or CustomType will depends on what I pass to type field.
Entire example will be used to build type for values in onSubmit handler which will define available fields (by id from fields data) and depends what it defined in type field in input data (union type).