Skip to content

Commit 8057704

Browse files
committed
fix: proxyObject ignore empty type
1 parent be32630 commit 8057704

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/proxyObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default function proxyObject<
55
Obj extends object,
66
ExtendObj extends object
77
>(obj: Obj, extendProps: ExtendObj): Obj & ExtendObj {
8-
if (typeof Proxy !== 'undefined') {
8+
if (typeof Proxy !== 'undefined' && obj) {
99
return new Proxy(obj, {
1010
get(target, prop) {
1111
if (extendProps[prop]) {

tests/proxyObject.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ describe('proxyObject', () => {
1212

1313
expect(proxyA.bamboo).toBe('little');
1414
});
15+
16+
it('null', () => {
17+
const proxyA = proxyObject(null, {
18+
bamboo: 'little',
19+
});
20+
21+
expect(proxyA).toBe(null);
22+
});
1523
});

0 commit comments

Comments
 (0)