I want to add a function on CanvasRenderingContext2D. what it does is to draw a circle text.
in javascript, all I need to do is write code like this:
CanvasRenderingContext2D.prototype.fillTextCircle = function () {
//some code
}
however it desen't work in typescript.
I also try these two methods:
1. add following code at the file header
interface CanvasRenderingContext2D {
fillTextCircle: any;
}
CanvasRenderingContext2D.prototype.fillTextCircle = function () {
//some code
}
2. add this line in lib.dom.d.ts
interface CanvasRenderingContext2D extends CanvasState, CanvasTransform, CanvasCompositing, CanvasImageSmoothing, CanvasFillStrokeStyles, CanvasShadowStyles, CanvasFilters, CanvasRect, CanvasDrawPath, CanvasUserInterface, CanvasText, CanvasDrawImage, CanvasImageData, CanvasPathDrawingStyles, CanvasTextDrawingStyles, CanvasPath {
readonly canvas: HTMLCanvasElement;
fillTextCircle: any; //add this line in lib.dom.d.ts
}
but it still complains this error:
Property 'fillTextCircle' does not exist on type 'CanvasRenderingContext2D'.