The weeb for the next gen discord boat - Wamellow wamellow.com
bot discord
at master 857 B view raw
1type RecursivePartial<T> = { 2 [P in keyof T]?: RecursivePartial<T[P]>; 3}; 4 5export function deepMerge<T>(target: T | undefined, source: RecursivePartial<T>): T | undefined { 6 if (typeof target !== "object" || typeof source !== "object" || !target) { 7 return target; 8 } 9 10 for (const key in source) { 11 if (Object.prototype.hasOwnProperty.call(source, key)) { 12 const targetValue = target[key]; 13 const sourceValue = source[key]; 14 15 if (typeof targetValue === "object" && typeof sourceValue === "object") { 16 // @ts-expect-error Some exteractor error 17 target[key] = deepMerge(targetValue, sourceValue); 18 } else { 19 // @ts-expect-error Some exteractor error 20 target[key] = sourceValue; 21 } 22 } 23 } 24 25 return target; 26}