Flow error overwriting DOM element protoype methods

时间:2018-08-22 13:49:49

标签: canvas prototype flow

I want to overwrite the strokeText function of the CanvasRenderingContext2D prototype. It works in terms of "does what it is supposed to do", but I get a flow error which I have trouble fixing.

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ src/modules/Document.js:27:40

Cannot assign function to CanvasRenderingContext2D.prototype.strokeText because property strokeText is not writable.

 24│     this.strokeText = CanvasRenderingContext2D.prototype.strokeText;
 25│     this.fillText = CanvasRenderingContext2D.prototype.fillText;
 26│     this.drawImage = CanvasRenderingContext2D.prototype.drawImage;
 27│     CanvasRenderingContext2D.prototype.strokeText = function noop() {};
 28│     CanvasRenderingContext2D.prototype.fillText = function noop() {};
 29│   }
 30│

Any pointers?

0 个答案:

没有答案