Skip to content

Commit

Permalink
fix: improve type safety in retargeting proxy setter
Browse files Browse the repository at this point in the history
- Add type checking for setter functions
- Ensure only valid function setters are called
- Prevent potential runtime errors with explicit type validation
  • Loading branch information
alvarosabu committed Feb 6, 2025
1 parent 9d5f43c commit 6d8e742
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils/primitive/createRetargetingProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export function createRetargetingProxy<T extends Record<string | number | symbol
return _target[prop]
},
set(_: any, prop: K, val: T[K]) {
if (setters[prop]) {
setters[prop](val, _target, proxy, setTarget)
const setter = setters[prop]
if (setter && typeof setter === 'function') {
setter(val, _target, proxy, setTarget)
}
else {
_target[prop] = val
Expand Down

0 comments on commit 6d8e742

Please sign in to comment.