I am currently working on creating a type that will modify a generic type based on its children. To provide some clarity, I have created a simplified example below:
Original type
type FormFields = {
username: {
type: string,
name: 'User Name'
},
password: {
type: string,
name: 'Password (must be strong)'
};
}
I want to transform it so that it can be utilized as
const userInput: UserInput<FormFields> = ...;
where the type of userInput
would essentially be
{username: string, password: string}
Ideally, I attempted something like this, but encountered an error:
type UserInput<T> = {
[K in keyof T]: T[K]['type'];
}
Any assistance or guidance in the right direction would be highly appreciated!