@@ -72,6 +72,25 @@ export function mergeGlobalProperties(
7272export const isObject = ( obj : unknown ) : obj is Record < string , any > =>
7373 ! ! obj && typeof obj === 'object'
7474
75+ function isClass ( obj : unknown ) {
76+ if ( ! ( obj instanceof Object ) ) return
77+
78+ const isCtorClass =
79+ obj . constructor && obj . constructor . toString ( ) . substring ( 0 , 5 ) === 'class'
80+
81+ if ( ! ( 'prototype' in obj ) ) {
82+ return isCtorClass
83+ }
84+
85+ const prototype = obj . prototype as any
86+ const isPrototypeCtorClass =
87+ prototype . constructor &&
88+ prototype . constructor . toString &&
89+ prototype . constructor . toString ( ) . substring ( 0 , 5 ) === 'class'
90+
91+ return isCtorClass || isPrototypeCtorClass
92+ }
93+
7594// https://stackoverflow.com/a/48218209
7695export const mergeDeep = (
7796 target : Record < string , unknown > ,
@@ -80,8 +99,13 @@ export const mergeDeep = (
8099 if ( ! isObject ( target ) || ! isObject ( source ) ) {
81100 return source
82101 }
102+
83103 Object . keys ( source )
84- . concat ( Object . getOwnPropertyNames ( Object . getPrototypeOf ( source ) ?? { } ) )
104+ . concat (
105+ isClass ( source )
106+ ? Object . getOwnPropertyNames ( Object . getPrototypeOf ( source ) ?? { } )
107+ : Object . getOwnPropertyNames ( source )
108+ )
85109 . forEach ( ( key ) => {
86110 const targetValue = target [ key ]
87111 const sourceValue = source [ key ]
0 commit comments