简体   繁体   中英

Visual Studio Code autocomplete/IntelliSense not working properly for JavaScript

vscode 自动完成的图像
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.
函数内的自动完成

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.
}

图像

For variables you can also use @type:

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

图像

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 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM