Skip to content

Commit

Permalink
fix: type asign (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed May 25, 2023
1 parent 8a24d1a commit 6da9531
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export function merge<T extends object>(...sources: T[]) {
loopSet.add(value);

// Init container if not exist
if (!get(clone, path)) {
const originValue = get(clone, path);
if (!originValue || typeof originValue !== 'object') {
clone = set(clone, path, createEmpty(value));
}

Expand Down
8 changes: 8 additions & 0 deletions tests/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ describe('utils', () => {
},
});
});

it('different type', () => {
const merged = merge({ selector: 'K1' }, { selector: ['K1', 'K2'] });

expect(merged).toEqual({
selector: ['K1', 'K2'],
});
});
});
});

Expand Down

1 comment on commit 6da9531

@vercel
Copy link

@vercel vercel bot commented on 6da9531 May 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

util – ./

util-react-component.vercel.app
util.vercel.app
util-git-master-react-component.vercel.app

Please sign in to comment.