We have a function such as below
export const objectUndefinedToNull = (obj) => {
const apply = (o) => {
Object.keys(o).forEach((key) => {
const value = o[key];
if (value === undefined) {
o[key] = null;
}
if (value instanceof Array || value instanceof Object) {
apply(value || {});
}
});
};
apply(obj);
return obj;
};
I would like to replace all any
and unknown
types for more appropriate types.
Is there any type that stands for any iterable types such as an array or object that can be iterated?