Visual Studio Code 像在 WebStorm 中一样启用建议代码 JavaScript [英] Visual Studio Code enable suggestion code JavaScript like in WebStorm

查看:48
本文介绍了Visual Studio Code 像在 WebStorm 中一样启用建议代码 JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

在 WebStorm 中,我有所有与 remov 匹配的建议,但在 VSC 中我有信息:没有建议.

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:

如何在 Visual Studio 中为 JavaScript 启用 Intellisense代码

用于 JavaScript 的 VSCode 智能感知自动完成

VS Code 自动完成基于文件中的单词

我有 VSC 1.24.0 版本

I have version VSC 1.24.0

我的 settings.json 文件:

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
}

我使用的所有代码:

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 的智能感知无法推断 divCnt 的类型,因为它没有在构造函数中赋值.您可以通过在构造函数中分配值或使用 jsdocs 来启用适当的智能感知:

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);
}

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

这篇关于Visual Studio Code 像在 WebStorm 中一样启用建议代码 JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆