Ad

Visual Studio Code Javascript Intellisense Not Working On Event Object Properties

I noticed when trying to call the .target property on the event parameter i'm passing thru, the intellisense doesn't recognize and give me options of the available properties or methods.

Is this normal functionality or is there a way to work around this?

https://i.stack.imgur.com/7rN04.png

Ad

Answer

You should be able to make it work by using JSDoc type annotations:

/**
 * @param event {YourTypeHere}
 */
let sharePhoto = function (event) {
    // TODO: Write code
}

For example, if you type Event in between the brackets:

A Visual Studio Code screenshot showing that IntelliSense works after giving 'event' an 'Event' type annotation

Ad
source: stackoverflow.com
Ad