I'm facing a challenge with my specific type:
type OtpCode = {
one: string;
two: string;
three: string;
four: string;
five: string;
six: string;
};
I want to iterate through this object and assign values:
Object.keys(defaultValues).forEach((x, i) => {
codeValuesForm.setValue(x, 'sometesttext');
});
The type of x is OtpCode, and Typescript is giving me an error stating
Argument of type 'string' is not assignable to parameter of type '"one" | "two" | "three" | "four" | "five" | "six"'.
How can I resolve this issue to successfully iterate through this object?