fix type of deepMerge
This commit is contained in:
parent
ca94959fff
commit
194bc20af1
|
@ -18,7 +18,7 @@ function isPureObject(value: unknown): value is Record<string | number | symbol,
|
||||||
* valueにないキーをdefからもらう(再帰的)\
|
* valueにないキーをdefからもらう(再帰的)\
|
||||||
* nullはそのまま、undefinedはdefの値
|
* nullはそのまま、undefinedはdefの値
|
||||||
**/
|
**/
|
||||||
export function deepMerge<X extends Record<string | number | symbol, unknown>>(value: DeepPartial<X>, def: X): X {
|
export function deepMerge<X extends object>(value: DeepPartial<X>, def: X): X {
|
||||||
if (isPureObject(value) && isPureObject(def)) {
|
if (isPureObject(value) && isPureObject(def)) {
|
||||||
const result = deepClone(value as Cloneable) as X;
|
const result = deepClone(value as Cloneable) as X;
|
||||||
for (const [k, v] of Object.entries(def) as [keyof X, X[keyof X]][]) {
|
for (const [k, v] of Object.entries(def) as [keyof X, X[keyof X]][]) {
|
||||||
|
|
Loading…
Reference in New Issue