visual-studio-code

HTML5 canvas intellisense in Visual Studio Code


is there a way to get intellisense for the HTML5 canvas element? In VS Code 0.7.10 when I write in my JS code this:

context = document.getElementById(canvasId).getContext('2d');

then when I write

context. 

I do not have any intellisense help for my context.

Thanks.


Solution

  • VS Code can support it!

    Just tell VS Code what type is the context. Adding the following code on your variable then the VS Code will know what it is. Sorry that I don't have enough point to post the image. Just click the solution to see how it works.

    /** @type {CanvasRenderingContext2D} */

    solution