简体   繁体   English

Visual Studio Code启用WebStorm中的建议代码JavaScript

[英]Visual Studio Code enable suggestion code JavaScript like in WebStorm

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: 我正在寻找一种解决方案,如何启用对JavaScript代码的所有建议,例如,我在VSC和WebStorm中编写了相同的代码:

在此处输入图片说明

In WebStorm I have all suggestion that match the word remov , but in VSC I have information: No suggestions. 在WebStorm我有相匹配的话,所有的建议remov ,但在VSC我的信息: No suggestions.

I try use answer from this question, but nothing work: 我尝试使用此问题的答案,但没有任何效果:

How to enable Intellisense for JavaScript in Visual Studio Code 如何在Visual Studio Code中为JavaScript启用Intellisense

VSCode intelliSense autocomplete for javascript VSCode intelliSense自动完成javascript

VS Code autocompletion base on word in file 基于文件中单词的VS Code自动补全

I have version VSC 1.24.0 我有版本VSC 1.24.0

My settings.json file: 我的settings.json文件:

{
    "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();
        };

    }

});

VS Code's intellisense cannot infer the type of divCnt since it is not assigned in the constructor. VS Code的intellisense无法推断divCnt的类型,因为它未在构造函数中分配。 You can enable proper intellisense by either assigning the value in the constructor or by using jsdocs: 您可以通过在构造函数中分配值或使用jsdocs来启用适当的智能感知:

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

Root cause is https://github.com/Microsoft/TypeScript/issues/10868 根本原因是https://github.com/Microsoft/TypeScript/issues/10868

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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