# Proxy drilling once again ...

**URL:** <https://es.discourse.group/t/proxy-drilling-once-again/1850>\
**Category:** I have questions\
**Tags:** proxy\
**Created:** [November 17, 2023, 2:36pm UTC](https://es.discourse.group/t/proxy-drilling-once-again/1850 "2023-11-17T14:36:44Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![bakkot](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/bakkot/32/22_2.png) [@bakkot](https://es.discourse.group/u/bakkot)\
**Post date:** [November 17, 2023, 8:28pm UTC](https://es.discourse.group/t/proxy-drilling-once-again/1850/15 "2023-11-17T20:28:38Z")

</div>

For you and anyone else writing a Proxy, I really recommend reading the NOTEs in the [Proxy section of the spec](https://tc39.es/ecma262/multipage/ordinary-and-exotic-objects-behaviours.html#sec-proxy-object-internal-methods-and-internal-slots). You don't need to read the algorithms themselves; every trap has a NOTE after which describes the invariants enforced for that trap. Anyone writing a Proxy _must_ ensure that those invariants are upheld, or you'll run into TypeErrors, as you have here. Some (possibly all) of these are mentioned on MDN, but the spec is the canonical source. If you find that MDN is missing some, it's now [on GitHub](https://github.com/mdn/content/) and easy to contribute to.

Like [I said in the last thread](https://es.discourse.group/t/the-array-isarray-shenanigans/1745/20), there's a bunch of stuff you have to decide up front when making a Proxy - this includes whether it's going to be an Array according to `isArray` and whether the `typeof` will be `object` or `function`, but also a whole bunch of other things, especially around non-configurable properties. There are [some things](https://tc39.es/ecma262/multipage/ecmascript-data-types-and-values.html#sec-invariants-of-the-essential-internal-methods) that, _by design_, you simply cannot do, with a Proxy or with anything else. The _only_ purpose of the `target` is to enforce this.

I doubt we're going to add any new Proxy traps. (It's not even clear that it would be web-compat to do so.) But if you want to suggest one, to have _any hope at all_ of being in the language, you need to ensure that the trap cannot be used to violate the essential invariants. Your proposed `valueOf` trap looks like it would make it trivial to violate the essential invariants.

---

_[View the full topic](https://es.discourse.group/t/proxy-drilling-once-again/1850)._
