2

I am looking for a solution how can I enable all suggestions for JavaScript code, for example I write this same code in VSC and WebStorm:

enter image description here

In WebStorm I have all suggestion that match the word remov, but in VSC I have information: No suggestions.

I try use answer from this question, but nothing work:

How to enable Intellisense for JavaScript in Visual Studio Code

VSCode intelliSense autocomplete for javascript

VS Code autocompletion base on word in file

I have version VSC 1.24.0

My settings.json file:

{
    "php.validate.executablePath": "C:\\php7\\php.exe",
    "workbench.iconTheme": "vscode-icons",
    "files.associations": {
        "*.ejs": "html",
        "*.js": "javascript"
    },
    "css.fileExtensions": [
        "css",
        "scss"
    ],
    "sublimeTextKeymap.promptV3Features": true,
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.snippetSuggestions": "top",
    "editor.formatOnPaste": true,
    "editor.wordWrap": "on",
    "window.menuBarVisibility": "toggle",
    "window.zoomLevel": 0,
    "workbench.colorTheme": "Afterglow",
    "editor.fontSize": 14,
    "editor.renderIndentGuides": false,
    "files.autoSave": "onFocusChange",
    "vsicons.dontShowNewVersionMessage": true,
    "editor.quickSuggestions": {
        "other": true,
        "comments": true,
        "strings": true
    },
    "editor.quickSuggestionsDelay": 1,
    "editor.suggestOnTriggerCharacters": true,
    "editor.wordBasedSuggestions": true,
    "editor.parameterHints": true
}

Edit:

All code which I use:

document.addEventListener("DOMContentLoaded", function () {


    function Calendar(input) {
        this.now = new Date();
        this.day = this.now.getDate();
        this.month = this.now.getMonth();
        this.year = this.now.getFullYear();

        this.input = input; 
        this.divCnt = null; 
        this.divHeader = null; 
        this.divTable = null; 
        this.divDateText = null; 
        this.divButtons = null; 


        this.init = function() {

            this.divCnt = document.createElement('div');
            this.divCnt.classList.add('calendar');

            this.divButtons = document.createElement('div');
            this.divButtons.className = "calendar-prev-next";

            this.divDateText = document.createElement('div');
            this.divDateText.className = 'date-name';

            this.divHeader = document.createElement('div');
            this.divHeader.classList.add('calendar-header');

            this.divHeader.appendChild(this.divButtons);
            this.divHeader.appendChild(this.divDateText);

            this.divHeader.appendChild();
        };

    }

});
michal
  • 1,534
  • 5
  • 28
  • 62
  • You need to provide a more complete code example that shows how `divHeader` is declared and assigned – Matt Bierner Jun 08 '18 at 04:53
  • This is not about the `divHeader` declaration. I just gave a brief example. I just want to force a syntax suggestion like the webstorm does. – michal Jun 08 '18 at 07:47
  • I need more context because that context is what determines why intellisense is not be showing here. Please provide a complete code example – Matt Bierner Jun 08 '18 at 19:58
  • @MattBierner i edit my post. And I check Sublime Text 3, in this program suggestions appear correctly as in WebStom. Only in VSC suggestions do not work correctly. – michal Jun 08 '18 at 20:12

1 Answers1

1

VS Code's intellisense cannot infer the type of divCnt since it is not assigned in the constructor. You can enable proper intellisense by either assigning the value in the constructor or by using jsdocs:

function Calendar(input) {
    this.divCnt = /** @type {HTMLDivElement} */ (null);
}

Root cause is https://github.com/Microsoft/TypeScript/issues/10868

Matt Bierner
  • 58,117
  • 21
  • 175
  • 206