Skip to content

Commit

Permalink
Refactor deepMerge function to fix type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
oekazuma committed Oct 24, 2024
1 parent 3da8b63 commit 37e6e8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-houses-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-meta-tags': patch
---

Refactor deepMerge function to fix type issue
7 changes: 4 additions & 3 deletions packages/svelte-meta-tags/src/lib/deepMerge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const deepMerge = <X extends Record<string | symbol | number, unknown>>(target: X, source: X): X => {
/* eslint-disable @typescript-eslint/no-explicit-any */
export const deepMerge = <X extends Record<string | symbol | number, any>>(target: X, source: X): X => {
if (!target || !source) return target ?? source ?? ({} as X);

return Object.entries({ ...target, ...source }).reduce((acc, [key, value]) => {
Expand All @@ -23,7 +24,7 @@ export const deepMerge = <X extends Record<string | symbol | number, unknown>>(t
}, {} as X);
};

const isObject = (obj: unknown): obj is Record<string | symbol | number, unknown> =>
const isObject = (obj: any): obj is Record<string | symbol | number, any> =>
obj !== null && typeof obj === 'object' && !Array.isArray(obj);

const isArray = (obj: unknown): obj is unknown[] => Array.isArray(obj);
const isArray = (obj: any): obj is any[] => Array.isArray(obj);

0 comments on commit 37e6e8d

Please sign in to comment.