1
我不知道如何清除這個警告:關閉編譯器警告 - HTMLCanvasElement和元素類型不匹配
WARNING - actual parameter 1 of
CanvasRenderingContext2D.prototype.drawImage does not match formal parameter
found : Element
required: (HTMLCanvasElement|HTMLImageElement|HTMLVideoElement|null)
ctx.drawImage(poolCanvas, rect.x, rect.y);
下面是相關代碼:
var /** @type {HTMLCanvasElement|Element} */ poolCanvas = document.createElement('canvas');
var /** @type {CanvasRenderingContext2D} */ ctx;
...
ctx.drawImage(poolCanvas, rect.x, rect.y);
我已經試過類型的各種組合聲明和我無法擺脫這個警告。
我在這裏做錯了什麼?