visual-studio-codeautocompletejavascript-intellisense

Javascript Text Prediction on VS Code Not Working


So i'm studying JavaScript on VS Code and as i progress, i recently discovered that when i'm starting to write a JavaScript built-in / native function, i have some text predictions like for example "fa4-ils" if i want to type filter(), also predictions on already declared variables work, but i will not see "filter()" or "endsWith()" being proposed to me while i'm writing.

Mabe it's normal, after all i'm not that knowledegable on VS Code, but i thought that IntelliSense was taking care of that. It looks like something is wrong. Here are the extensions I have installed and enabled that could mean something:

auto rename tag, better comments, bootstrap 4, "font awesome 4, font", code spell checker, esLint, french language pack for VS Code, intelliCode, intelliCode API Usage Examples, javascript (es6) code snippets, jQuery code snippets, markdown all in one, prettier - code formatter, quokka, standardJS -javascript standard sty.

Also, i uninstalled / reinstalled twice the app, and i'm on PC. Could someone enlight me ?

// What i Tried, imagine i'm actually writing str.fil
function solution(str) {
    return str.fil
}

// Expectin VS Code to propose me the function more or less like that : str.filter()
function solution(str) {
    return str.filter()
}

// result : this is what is proposed to auto-fill : fa4-ils, fa4-life-ring, fa4... all starting with fa4

Solution

  • These are called "suggestions" in VS Code. You need to give your parameter a type annotation. You can do that in VS Code by using JSDoc's @type annotation.

    For example, if your parameter is an array of strings:

    function solution(/** @type {String[]}*/str) {
    

    or

    /**
     * @param str {String[]}
     */
    function solution(str) {
    

    Type Intellisense in the type annotations in VS Code uses TypeScript syntax. See the TypeScript docs for more info.

    Make sure that the language mode for the open editor is set to JavaScript. It looks like it might not be from the fact that you're getting suggestions that are typically hard to use as JS function names- a different language other that JavaScript might have gotten auto-detected for your open editor. You can change the language mode using the selection input at the bottom right, or using the Change Language Mode command in the command palette.