-
Notifications
You must be signed in to change notification settings - Fork 583
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
Bug: can't extend the native Map/WeakMap/Set/WeakSet class #2107
Comments
I suspect that the below statement throws an error that the "new" operator is required.
In the ES6 program, the above corresponds to the statement "super();". |
Referencing the feedback from the previus issue: #1413, it works as design. |
There is a work around: Compile: class M extends Map {
constructor() {
super();
}
} to: class M extends Map {
constructor() {
const self = new Map();
self.__proto__ = M.prototype; // should really be new.targe.prototype
return self;
}
} but there are 2 issues making this hard:
|
|
You cannot touch Another problem would be sub classing |
Sure, it's approach for a compiled code, I use it for a long time.
Here required complete subclassing reform like in |
Bug: can't extend the native Map/WeakMap/Set/WeakSet class.
Description: Only the ES 6 classes can't be extended. However, both the traditional built-in classes (e.g. Date) and the custom classes are able to be successfully extended to instantiate a sub class.
Source code:
Run the JavaScript file by:
Runtime Error:
The text was updated successfully, but these errors were encountered: