-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extending Error is flaky because Error.call
returns a new object
#40
Comments
Oh, even with that fix, the resulting instances are not It does work when you directly use |
Ah, I wasn't even talking about this causing a problem in the Bublé sources (I hadn't noticed)—rather it was causing trouble in my own projects. But I've fallen back on directly writing the horrible ES5 code needed to create a subclass of Error for now, and I guess I'll just keep doing that until the next geological era when I can ship client-side ES6 code. So this isn't blocking me. |
As discussed in the babel issue, whether extending builtins is allowed should probably be configurable, right? |
I.e.
let x = {}; Error.call(x) == x
produces false, at least on Firefox and Chrome. This is preventing Error subclasses compiled with Bublé from gettingstack
andmessage
properties, making them rather useless.Babel works around this by creating a new binding to replace
this
inside the constructor, storing the result of the super constructor call in that, and returning it at the end. Would that be something that Bublé would be interested in adding? I might be able to create a PR.The text was updated successfully, but these errors were encountered: