Visual Studio Code autocomplete/IntelliSense not working properly for JavaScript

Viewed 9822

Image of vscode autocomplete
It's not displaying the properties of an array like length etc.

I'm not sure if this is a problem or this is expected behavior of VScode's autocomplete/IntelliSense.

Do I need to install any extensions to make it work?

Edit:
On adding var or let before arr the autocomplete works fine normally but inside a function it doesn't work.
autocomplete inside a function

3 Answers

Check if the building extension TypeScript and JavaScript Language Features is enabled.

To check this, go to Extensions and search for @builtin TypeScript and JavaScript Language Features.

This should look something like this: [![vscode][1]][1]

Edit:

Also, check if you choosed the right language?

  • -> CTRL (or CMD) + P
  • -> > Change Language Mode
  • -> JavaScript

Another thing I noticed: You have no var, let or const before the variable, see stackoverflow.com/a/51962449/14401587

Edit 2:

IntelliSense does not know what types the parameters have for functions. But you can use the @param annotation in the comment:

/**
 * 
 * @param {Array} arr 
 */
function a(arr) {
    arr.
}

img

For variables you can also use @type:

/** @type {Array} */
let a;

img

Go to Extensions and search for @builtin TypeScript and JavaScript Language Features. Try stopping and restarting this plugin and restart VS Code. Looks like a bug. This fixed it for me.

For me I just stop the TypeScript and JavaScript Language Features extension, and it works fine, maybe a bug or a conflict with other extensions I think

Related