Hi,
I'm trying to initialize an object that looks like this:
type InitialValues = Record<keyof typeof formSchema, string>;
where FormSchema is an object that defines validator functions
const formSchema = {
username: usernameValidator;
email: emailValidator;
...
}
and I want all the initial values to be blank. Is there any way I can do this? I would do it like this if I were using JavaScript:
let initialValues: InitialValues = {}
for (const name of Object.keys(formSchema)) {
initialValues[name] = '';
}
but that gives me the error
Type '{}' is not assignable to type 'Record<keyof TypeOf<formSchema>, string>'
Any help for the right way to approach this would be great. Thank you!