Skip to content

Commit

Permalink
fix: proxyObject ignore empty type
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed May 17, 2024
1 parent be32630 commit 8057704
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/proxyObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function proxyObject<
Obj extends object,
ExtendObj extends object
>(obj: Obj, extendProps: ExtendObj): Obj & ExtendObj {
if (typeof Proxy !== 'undefined') {
if (typeof Proxy !== 'undefined' && obj) {
return new Proxy(obj, {
get(target, prop) {
if (extendProps[prop]) {
Expand Down
8 changes: 8 additions & 0 deletions tests/proxyObject.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ describe('proxyObject', () => {

expect(proxyA.bamboo).toBe('little');
});

it('null', () => {
const proxyA = proxyObject(null, {
bamboo: 'little',
});

expect(proxyA).toBe(null);
});
});

0 comments on commit 8057704

Please sign in to comment.