6

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

atin
  • 985
  • 3
  • 11
  • 28

3 Answers3

24

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

Daniel
  • 1,426
  • 1
  • 11
  • 24
  • Yes @Daniel this is enabled but still not working. – atin Dec 07 '20 at 14:02
  • @at-in Choosed the right language? CTRL (or CMD) + P -> `> Change Language Mode` -> `JavaScript` – Daniel Dec 07 '20 at 14:04
  • @at-in Another thing I noticed: You have no var, let or const before the variable, see https://stackoverflow.com/a/51962449/14401587 – Daniel Dec 07 '20 at 14:08
  • on adding `let` or `var` it works fine but inside a function it doesn't work. I'll edit my question a bit to explain this – atin Dec 07 '20 at 14:39
  • Just a suggestion @Daniel, you should add the `let`/`var` thing in your answer since this is also a problem someone else might face. – atin Dec 07 '20 at 14:44
  • What was the answer? I get the same issue. When I jump inside a function or method, the auto-completion won't be enabled. – m3.b Nov 16 '21 at 03:50
  • Thanks man, big help was actually going crazy trying to fix this. – Mernlin Dec 22 '21 at 09:26
  • off topic: which font is that (Vscode)? @Daniel – manukn Dec 10 '22 at 07:06
  • @manukn I think I used [Fira Code](https://github.com/tonsky/FiraCode) in the screenshots – Daniel Dec 11 '22 at 16:43
5

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.

rahulspoudel
  • 51
  • 1
  • 2
0

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

waakemeup
  • 11
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 08 '22 at 08:13