We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8a24d1a commit 6da9531Copy full SHA for 6da9531
src/utils/set.ts
@@ -82,7 +82,8 @@ export function merge<T extends object>(...sources: T[]) {
82
loopSet.add(value);
83
84
// Init container if not exist
85
- if (!get(clone, path)) {
+ const originValue = get(clone, path);
86
+ if (!originValue || typeof originValue !== 'object') {
87
clone = set(clone, path, createEmpty(value));
88
}
89
tests/utils.test.js
@@ -179,6 +179,14 @@ describe('utils', () => {
179
},
180
});
181
182
+
183
+ it('different type', () => {
184
+ const merged = merge({ selector: 'K1' }, { selector: ['K1', 'K2'] });
185
186
+ expect(merged).toEqual({
187
+ selector: ['K1', 'K2'],
188
+ });
189
190
191
192
0 commit comments