I'm trying to deeply proxy the properties of a frozen object:
const a = Object.freeze([{ prop: 1 }])
const proxy = new Proxy(a, {
get(target, property) {
return new Proxy(target[property], {});
}
})
console.log(proxy[0])
This produces a type error:
TypeError: 'get' on proxy: property '0' is a read-only and non-configurable data property on the proxy target but the proxy did not return
and I see that get
proxies have the following restriction:
The value reported for a property must be the same as the value of the corresponding target object property if the target object property is a non-writable, non-configurable own data property. - es6 spec
Is there any way to have nested proxies on a frozen object?