-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Cannot extend native Error class #7639
Comments
looks like a duplicate of #5069, please see the discussion in #1168 (comment) |
I did. @ahejlsberg says:
Relevant PR contains an example: class MyError extends Error { } It compiles fine. What I'm trying to figure is why doesn't it work in compiled js? |
it can. the compiler does not complain at you any more. the problem is not the TS compiler. the problem here is that these classes are native, your runtime does not support extending them at the moment. In the future i would expect all these native types to be conformant with ES6 spec. @unional has a comment on how to get it to work with the engines today: #1168 (comment). |
@mhegazy , wow, you got good memory. 👍 |
Ok, I feel a little awkward here, but that example doesn't compile:
From what I can take from there, the suggested solution is to do |
The first line is a guard. You can take it out. The compiler has changed since then. |
Am I missing something obvious or is there a bug with 1.8.9?
The text was updated successfully, but these errors were encountered: