HTML5 canvas intellisense in Visual Studio Code

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

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

then when i write

 context. 

I have no intellisense help for my context.

Thanks.

+7
visual-studio-code
source share
1 answer

This is currently not supported by VS Code and is difficult to fix. Because JavaScript does not contain type annotations, VS Code tries to make the most of stream types. In your example, document.getElementById breaks this stream because from spec it can return any html element (and we no longer know the html structure or the canvasId value).

Something like this would be more beneficial for VS Code:

var canvas = document.createElement('canvas'); canvas.|

Alternatively, you can learn TypeScript because there you use type annotations and type castings.

+6
source share

All Articles