VS 代码不会将未使用的变量变灰

VS code doesn't gray out unused variables

据我所知,这似乎是您在 settings.json 中输入的设置,用于启用未使用的变量和未使用的导入,这些变量和导入显示为灰色。

"editor.showUnused": true,

我确实有下划线,如果您将鼠标悬停,我会在悬停时看到下划线和消息。

我错过了什么?

在我的 settings.json 中,显然我评论说以下内容起到了作用。

 "javascript.validate.enable": true,

/* this controls having your unused imports or variables to appear grey */

*内置语言功能扩展解决方案:

我添加这个是为了防止有人像我一样被卡住。我遇到了同样的问题,问题如下。

vscode 有 @builtin 个扩展名。其中之一是 typescript and javascript language features。如果它被禁用,这些功能将无法工作。所以只需转到扩展并搜索@builtin typescript and javacsrtipt language feature`,单击齿轮图标并启用扩展。

2020 年 9 月

对我来说,在 .vscode 目录的 settings.json 中添加 "editor.showUnused": true, 是可行的。