Is it possible to construct some type directly from the string provided?
I want to create a type something like shown below:
type MyConfiguration<T> = {
items: T[];
onChange: (updated: ConstructedType<T>) => void;
}
const conf: MyConfiguration = {
items: ['id', 'nested.id', 'nested.name'],
onChange: updated => {
console.log(`You updated ${updated.nested.name}(id: ${updated.nested.id})`);
},
};
So it will generate a type for updated to be {id: string; nested: { id: string; name: string}}