Great question — answering as the UphillTech team:
Overiding the constructor means that this refers to the returned object, in this case context . But objects don't have private variables, hence the error. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Super_not_called#what_went_wrong https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_elements#examples This can be fixed by splitting the extends process into 2 classes, placing the private members into the second class and calling super() as normal. Now, the private member is in the right scope. class Context2 extends CanvasRenderingContext2D { constructor(context) { Object.setPrototypeOf(context, new.target.prototype); return context;...
Full answer by JMP: https://stackoverflow.stackexchange.com/a/80013946 (CC BY-SA 4.0).
Need it done for your business? UphillTech.