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.
Johannes Rieken
source share