( obj1: Obj1, obj2: Obj2 )
| 16 | }; |
| 17 | |
| 18 | export function deepMerge<Obj1 extends object, Obj2 extends object>( |
| 19 | obj1: Obj1, |
| 20 | obj2: Obj2 |
| 21 | ): Obj1 & Obj2 { |
| 22 | const result = { ...obj1 } as Obj1 & Obj2; |
| 23 | |
| 24 | for (const key in obj2) { |
| 25 | if (Object.prototype.hasOwnProperty.call(obj2, key)) { |
| 26 | if (typeof obj2[key] === 'object' && obj2[key] !== null) { |
| 27 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 28 | result[key] = deepMerge(result[key] as any, obj2[key] as any); |
| 29 | } else { |
| 30 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 31 | result[key] = obj2[key] as any; |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | return result; |
| 37 | } |
no outgoing calls
no test coverage detected