type DeepCloneable = object | Array; export default function deepClone(obj: T): T { if (obj === null || typeof obj !== 'object') { return obj; } if (Array.isArray(obj)) { return obj.map(deepClone) as T; } const clone = {} as T; for (const key in obj) { clone[key] = deepClone(obj[key] as any); } return clone; }