Reflect.toStringSpec proposal

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Dec 14 03:37:24 UTC 2016


> On Dec 13, 2016, at 4:51 PM, Sergey R <chi187 at gmail.com> wrote:
> 
> I want to propose a new language feature — Reflect.toStringSpec.
> Here is a repo https://github.com/chicoxyzzy/proposal-reflect-tostringspec <https://github.com/chicoxyzzy/proposal-reflect-tostringspec>
> Some context: https://github.com/airbnb/babel-plugin-dynamic-import-node/pull/2/ <https://github.com/airbnb/babel-plugin-dynamic-import-node/pull/2/>_______________________________________________

Doesn’t this do exactly what you want:

```js
// JS level equivalent of ES spec ToString abstract operation https://tc39.github.io/ecma262/#sec-tostring <https://tc39.github.io/ecma262/#sec-tostring> 
function ToString(v) {
   if (typeof v === “symbol”) throw TypeError(“Can’t convert a symbol to a string”);
   return String(v);  //for non-symbols String(v) primitively returns ToString(v)
}
```

This seems like something that can reasonably be coded as part of a polyfill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20161213/3f5e0fdb/attachment.html>


More information about the es-discuss mailing list