Closed Xotic750 closed 6 years ago
Absolutely obj[key] = value
and Object.defineProperty(obj, key, { value })
should behave the same, that doesn't surprise me.
Primarily this looks like an engine bug that simply can not be fixed.
es6-shim doesn't shim Object.defineProperty
- that's ES5, and object-symbol support can't be shimmed. You're right that es6-shim could try to detect this case, but we'd end up creating an inconsistency between object brackets and Object.defineProperty
.
I'd recommend running any maybe-symbols through es-to-primitive
, if you want to work around this bug.
I know that it's edge case, but I thought it worth a mention. ;)
On node<6, the following code fails with
TypeError: Cannot convert object to primitive value
I know this is not fixable, however I thought that with ES6-shim loaded, that the following would work.
but it also fails.
TypeError: Cannot convert object to primitive value
ToPropertyKey
works fine, converting the symbol object to symbol primitive, soObject.defineProperty
can shimmed with the use ofToPropertyKey
to provide the expected result.This is also true for
hasOwnProperty
, because as it stands, while not throwing an error, this behaviour is observed.and again can be fixed with
ToPropertyKey
.