I have a helper function which updates the form based on the fieldname, e.g. if name, then form.name will be updated. If user[0].name, then name of index 0 of form.users will be updated. However I'm facing an error and it is simplified by the code below:
const example: Record<string, unknown> = {
'a': 'haha',
'b': [1,2,3],
};
const str = 'b.haha';
const tokens: string[] = str.split(".");
if (typeof example[tokens[0]][Symbol.iterator] === 'function') {
const c = [...example[tokens[0]];
}
I can't solve this Type 'unknown' must have a 'Symbol.iterator' method that returns an iterator. Thanks