A question regarding type construction from data structures. I have an array like this:
interface ICVSection {
namespace: string;
validation: Yup.ObjectSchema<any>;
}
const CVSections: ICVSection[] = [
{
namespace: 'common',
validation: CommonValidationSchema,
},
{
namespace: 'summary',
validation: SummarySchema,
}
/* ... */
};
So the question is: is it possible to somehow using the data above create following type:
type Schema = {
common: typeof CommonValidationSchema,
namespace: typeof SummarySchema,
/* ... */
}
I'm not 100% sure if it is possible in TypeScript, but if so, it would be great if someone can prove me right or wrong.